Found record not displaying when combo box requeried

F

Flick Olmsford

I have a Sales Contact database. I am creating a sales record form.

If a customer exists in the client table, some code in the afterupdate event
of the combo box on that form finds the client record and displays his / her
info on that form. This is working.

If the client does not appear in the combo box, I have a command button to
open another form (client form) so that the user can add the new client. In
both the close event for the client form and the click event of a command
button saving the record in the client form I have the following code

If
CurrentProject.AllForms("frm_Client_Contact_All_In_One_Main").IsLoaded Then
Forms![frm_Client_Contact_All_In_One_Main]![cbo_SearchByName].Requery
MsgBox "Requeried", vbOKOnly
End If

I am using Access 2003.

When I add a new record in the client form, I get the requeried message.
But when I go back to the form, the new client appears in the drop down list
in the client form, but the form does not display the record it should have
found. It will display info for all other records in the combo box.

I must close the Sales contact form and reopen it for the new client to not
only appear in the combo box, but also to display on the form when found.

Does anyone know why this would happen?
 
K

Klatuu

You are only requerying the combo on the form. You need to requery the
entire form. The combo will requery with it.

Change this line:
Forms![frm_Client_Contact_All_In_One_Main]![cbo_SearchByName].Requery

To:
Forms![frm_Client_Contact_All_In_One_Main].Requery

A form's recordset only includes records that were in the table at the time
the form was either loaded or last requeried or that have been added in the
current session.

But, before you requery this form, you also need to be sure the record has
been saved in the client form so it is in the table.
 
F

Flick Olmsford

Thanks. That worked. MS discussion groups come through again!


Klatuu said:
You are only requerying the combo on the form. You need to requery the
entire form. The combo will requery with it.

Change this line:
Forms![frm_Client_Contact_All_In_One_Main]![cbo_SearchByName].Requery

To:
Forms![frm_Client_Contact_All_In_One_Main].Requery

A form's recordset only includes records that were in the table at the time
the form was either loaded or last requeried or that have been added in the
current session.

But, before you requery this form, you also need to be sure the record has
been saved in the client form so it is in the table.

--
Dave Hargis, Microsoft Access MVP


Flick Olmsford said:
I have a Sales Contact database. I am creating a sales record form.

If a customer exists in the client table, some code in the afterupdate event
of the combo box on that form finds the client record and displays his / her
info on that form. This is working.

If the client does not appear in the combo box, I have a command button to
open another form (client form) so that the user can add the new client. In
both the close event for the client form and the click event of a command
button saving the record in the client form I have the following code

If
CurrentProject.AllForms("frm_Client_Contact_All_In_One_Main").IsLoaded Then
Forms![frm_Client_Contact_All_In_One_Main]![cbo_SearchByName].Requery
MsgBox "Requeried", vbOKOnly
End If

I am using Access 2003.

When I add a new record in the client form, I get the requeried message.
But when I go back to the form, the new client appears in the drop down list
in the client form, but the form does not display the record it should have
found. It will display info for all other records in the combo box.

I must close the Sales contact form and reopen it for the new client to not
only appear in the combo box, but also to display on the form when found.

Does anyone know why this would happen?
 
F

Flick Olmsford

Frankly, I was not aware of the NotInList event. I am sort of learning all
this Access Event coding as I go along.

I'll check that out. Thanks.


ruralguy via AccessMonster.com said:
The form itself would need to be requeried in order to update the recordset
the form has as a RecordSource. Why aren't you using the NotInList event of
the ComboBox to add clients?

Flick said:
I have a Sales Contact database. I am creating a sales record form.

If a customer exists in the client table, some code in the afterupdate event
of the combo box on that form finds the client record and displays his / her
info on that form. This is working.

If the client does not appear in the combo box, I have a command button to
open another form (client form) so that the user can add the new client. In
both the close event for the client form and the click event of a command
button saving the record in the client form I have the following code

If
CurrentProject.AllForms("frm_Client_Contact_All_In_One_Main").IsLoaded Then
Forms![frm_Client_Contact_All_In_One_Main]![cbo_SearchByName].Requery
MsgBox "Requeried", vbOKOnly
End If

I am using Access 2003.

When I add a new record in the client form, I get the requeried message.
But when I go back to the form, the new client appears in the drop down list
in the client form, but the form does not display the record it should have
found. It will display info for all other records in the combo box.

I must close the Sales contact form and reopen it for the new client to not
only appear in the combo box, but also to display on the form when found.

Does anyone know why this would happen?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top