combobox not on list problem?

  • Thread starter Thread starter Anne
  • Start date Start date
A

Anne

I have 2 comboboxes on a subform which seem to be set up identically, except
the 2nd one has a not on list event.

First Combo is to select JobNo, I can click into the field and select a job
or type a job.
the 2nd Combo is for a contact, linked to the main table by ContractorID.

The setup is equal to the job one.
Name is: txtContactID
ControlSource: ContactId (autonumber)
RowSource: cboContacts
column Count 2 - Column 2 = contact name
Bound col=1 (this is ContactID)

As soon as I try to type the new contact name, I get this error tone and
can't type.
I tried using contactName as bound column and everything worked fine, I
could type the new name, it would assign the next autonumber to the name,
but in the end, it would add 2 records instead of one. One would be
autonumber and name and then a second row with just a new autonumber, no
name.

Can someone tell me, where this goes wrong?
Anne
 
I have changed the bound column to ContactName again, and I am now
realizing, that when I add the name to the list, it creates the new name;
however, at that point I am not done entering data for that contact, I am
adding the contractorID the contact works for, the phone, the job etc.
As a matter of fact, for debugging purpost, I am displaying right now the
ContactID as a field in the row, and in this sample, the name that I am
still working on shows contactID 334, but the one already written to the
contact table has 335.

Anne
 
When the second combo box is "requeried" by your "NotInList" code, it saves
the record to the underlying recordsource, which is why you're seeing two
records. With your setup, you may want to have a command button next to the
second combo box, and use that command button to run code that allows the
person to enter a new name and to then requery the second combo box; set the
Limit To List property to Yes for this second combo box. That should get you
around this problem.
 
For right now, I converted the combo to a text box, because the relationship
to the main table shows all contacts anyway. Like you suggested I use a
command button to add records and it is working well.
This is a new portion of the program and I have to see what my client want
to see, all or none or only specific to a job. So I might revisit this
later.
For some reason I still have problems with the requery stuff on all kind of
occasions, and I thought I understood the controls etc. But I will put that
into a separate post.
Thank you,
Anne
 
Back
Top