Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.basic.visual.misc > #1855
| From | Jason Keats <jkeats@melbpcDeleteThis.org.au> |
|---|---|
| Newsgroups | comp.lang.basic.visual.misc |
| Subject | Re: Problem with ADO in VB6 |
| References | (10 earlier) <ihbuet$7lr$1@news.eternal-september.org> <ihbuih$9jp$1@news.eternal-september.org> <f0babd48-0e76-405f-ba94-3cf88ea0cf26@f30g2000yqa.googlegroups.com> <cYb2p.9528$gM3.3489@viwinnwfe01.internal.bigpond.com> <b063466e-660d-4777-b3e8-01e40ec5ec23@r16g2000yql.googlegroups.com> |
| Message-ID | <Lsd2p.9534$gM3.273@viwinnwfe01.internal.bigpond.com> (permalink) |
| Date | 2011-02-03 01:01 +1100 |
| Organization | BigPond |
jason@smkzone.com wrote:
> On Feb 2, 6:18 am, Jason Keats<jke...@melbpcDeleteThis.org.au> wrote:
>> ja...@smkzone.com wrote:
>>> Ok guys it's me again...lol
>>
>>> Same program, same topic, new problem.
>>
>> <snipped>
>>
>> Have you sorted out your problems?
>>
>> If not, please describe what it is you're trying to do.
>
> Haven't sorted it out yet.
>
> I have a dialog form in the program which appears whenever the user
> presses either the "Add," "Edit", or "Delete" button on the main form
> and executes a different sub depending on the caption of the dialog
> box ("Add Employee," "Edit Employee", "Delete Employee.") The dialog
> box has a Combobox control named cmbEmployee which is populated with
> the list from cmbName2 on the main form and has the same ListIndex and
> two textboxes, txtSSN and txtEmplNumber, which display the SSN field
> and Employee_Number field of the record selected in cmbName2. So far,
> so good. The problem comes when trying to execute the EditRecord
> sub. I need to set it up so that all the following occurs:
>
> 1. If the user edits the Employee_Name field, I need the original name
> removed from cmbEmployee.List and the new name added to the list,
> along with the ItemData of the original entry. I then need this
> update to appear in cmbName1, cmbName2, and cmbName3 on the main form
> as well.
>
> 2. If the user edits both Employee_Name and Employee_Number, I need
> both the name and itemdata changed in all the comboboxes to reflect
> the changes made to the recordset.
>
> 3. If the user changes only the Employee_Number but not the
> Employee_Name, then the ItemData of that entry needs to be changed on
> all the comboboxes.
>
> The problem seems to stem from the fact that if anything is typed into
> cmbEmployee, its ListIndex becomes -1.
>
> Hope that helps! :)
> Jason
Does that mean you've got "Add", "Edit" and "Delete" buttons which bring
up the dialog? I can understand showing a new form to add or edit, but
not to delete.
If you don't want to squeeze the above three button onto your form then
you might be able to get rid of the Delete button by using the Delete
key instead. You can also put an "<add new>" item in your combobox (up
the top) - which will allow you to remove the "Add" button. So, you
really only need an "Edit" button.
And, if you change the Style property of your combobox to "2 - Dropdown
List", then users won't be able to type anything - so you won't get the
ListIndex = -1 problem.
1. can only be done after you've learned to display the edit dialog and
save your changes.
2. You can only edit the Employee_Name, not the Employee_Number -
because the Employee_Number is a database generated (AutoNumber) primary
key. If you really wanted to change the Employee_Number then you would
have to delete the original record and insert a new one.
3. See the above.
If you want Employee_Number to be editable, then you can't use it as a
primary key. A primary key is really not meant to be seen or used by the
client - and is never meant to change.
Back to comp.lang.basic.visual.misc | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Problem with ADO in VB6 "jason@smkzone.com" <jbodine1@yahoo.com> - 2011-02-02 05:18 -0800
Re: Problem with ADO in VB6 Jason Keats <jkeats@melbpcDeleteThis.org.au> - 2011-02-03 01:01 +1100
Re: Problem with ADO in VB6 Jason Keats <jkeats@melbpcDeleteThis.org.au> - 2011-02-03 07:13 +1100
csiph-web