Update Table - Newbie needs help

  • Thread starter Thread starter Me
  • Start date Start date
M

Me

Scenario:
The user fills a form to generate a record. One of the
controls on the form is a combobox that lists names of
companies. However, in some instances the company he wants
may not be listed. He would therefore have to link to
another form to create the company in the appropriate
table.

How can I refresh the data in the combobox after creating
the new company without closing the form that contains the
combobox?
 
You have opened another form where the user enters the company, and you want
to requery the combo so it knows about the new company.

Use the AfterUpdate and AfterDelConfirm events of the Company form to
requery the combo on the original form. Something like this:

Private Sub Form_AfterUpdate(Cancel As Integer)
Forms!Form1![NameOfYourComboHere].Requery
End Sub
 
Me said:
Scenario:
The user fills a form to generate a record. One of the
controls on the form is a combobox that lists names of
companies. However, in some instances the company he wants
may not be listed. He would therefore have to link to
another form to create the company in the appropriate
table.

How can I refresh the data in the combobox after creating
the new company without closing the form that contains the
combobox?

You can use the NotInList event

The following is close to all that is needed. Consider any errors to be
pseudo code :).

If vbYes = msgbox("Company not in list, do you want to add it", vbYesNo)
then
DoCmd.openform YourCompanyAdd form ... ' This can be opened
modally and pass the new name to that form. Then when you close that form:
Me!YourCombo.requery
end If

I think the above came from "The Developers Handbook."
 
Back
Top