Requery a Combo Box After adding New Record To Its Source Row

G

Guest

Hi all

Im fairly new to access so forgive me if this is a simple question!

I basically have a form from which the user can select a customer and a
vehicle from two seperate combo boxes. This assumes the customer and vehicle
already exists! I want to be able to place a button next to each combo box
which, when pressed, will envoke a pop up form enabling the user to enter a
new customer or vehicle! Once they have entered the details on the form,
they can click save and the original forms combo box refresh's itself to
include the new record for the customer or vehicle!

I have tried the Requery form function but this removes all data previously
entered!

Any help would be greatly appreciated - once again some terminology is lost
on me as im fairly new to the subject!

Thanks

Drodway
 
B

BruceM

In the After Update event for the pop-up form you can requery the combo box.
I will call the form YourForm, and the combo box YourCombo. The Close event
for the pop-up form would then be:
Forms!YourForm!YourCombo.Requery
You could use other events such as the Close event for the code. I don't
know if there is an advantage to using one over the other.
 
G

Guest

BruceM

Thanks for the speedy reply - but this didnt work!

Basically i have a form "deal_new" which has a tab control "DN_TC" that has
a page "Deal"
on the "deal" page there is two combo boxes "C_LU" & "V_LU" which lookup
values stored in tables "customer" & "vehicle" respectfully. Next to the
C_LU combo box i have a small button which when pressed opens the form
"cust_new" while remaining open in the background. When i enter the details
on "cust_new" i click the button "save".

i have tried entering the code you gave but the box doesnt repopulate!
should i implement the request in macro builder? expression builder? code
builder?

im using Access 2007 - if this makes any difference?

Thanks in advance!

Drodway
 
B

BruceM

How did you enter the code? You would use Code Builder, or you could open
the VBA editor directly. It sounds as if you have found the option to use
Code Builder, but just to be sure, open the property sheet for your Save
command button on the cust_new form. Click the Event tab, click the Click
event row, and click the three dots. Click Code Builder, and OK.
You should also be able to right click the command button, and select Build
Event, but I don't know if that works for all versions of Access.
Anyhow, the cursor should be flashing between Private Sub YourButton_Click()
and End Sub. Add the code there. Be sure to use your exact form and combo
box names. Note that Forms! is the same in all cases. Do not change it.
I do not have Access 2007, but I expect the procedure is much the same as in
my Access 2003.
 

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