Passing data between forms

fnyokou

New member
Local time
Today, 21:30
Joined
Dec 12, 2020
Messages
7
I have a limited knowledge in Access. I am trying to build a database and i am facing an issue adding new customers from order form and get it automatically populate in a combo box in the order form. can anyone help?
 
Your title says "between forms" but your description is of the same form. In any case, if a customer got added via some method you may be able to requery the combo box for it to see the new customer.

Me.ComboName.Requery

If the code is on the same form as the combo.
 
1607796553427.png

Sorry, it is in French. They are two different forms.
 
From a different form the code would be:

Forms!FormName.ComboName.Requery
 
I have tried these codes but it did not work for me:
Me.refresh
If Not IsNull([Nom]) then
Form![Location].Form.ClientID= Me.ClientID
Form![Location].Form.ClientID.SetFocus
End If
DoCmd.Close
 
Error message is : run-time 2465. Location form cannot be located
 
Is it open when this code runs? It needs to be. Try:

Forms!Location.ClientID = Me.ClientID
 
This seems to work: Can I add the second (prenom) field to be populated?

Private Sub btnPrecedant_Click()
Forms!location.ClientID = Me.ClientID
DoCmd.Save
DoCmd.Close

End Sub
 
I don't understand the question or the answers so I'll try a different tact.

If you are starting from the Order form and you have a new customer who is not in your customer combo and you want to add the new customer and have him added to the combo so you can select him, then, use the not in list event of the combo to open the customer form. when you add the record, set the Response code to record added. I don't have the exact code because I never use this method but you can probably find an example of how the not in list event works.
What I would like to do is: to click on "add new customer" in Order form and get a pop up customer form opened in add mode, once I finish filling the form and click on "save and close", the customer form closes and the Order form opens with required information on the customer I have just entered being populated in the combo. With [U]pbaldy[/U] help I am able to make it work using below code in "save and close" button of the add new customer form. please let me know if you have another way.

Forms!location.ClientID = Me.ClientID
DoCmd.Save
Forms!location.ClientID.Requery
DoCmd.Close
 

Users who are viewing this thread

Back
Top Bottom