Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set value of combobox query from another form 1

Status
Not open for further replies.

MadBnz

Technical User
Jan 30, 2002
18
NZ
Hi, I have a Order form which has a combo box listing Clients. This is based on a query. The table has 'CID' and 'CName' fields. If the Client is not listed I have a button that calls up another form and prompts the user for the clients details (Name etc).
When this second form is closed I have managed to get it to requery the client table and have the new name in the list using the following code.

Private Sub Form_Close()
Forms!NewOrders!CID.Requery
End Sub

Is there anyway I can get the Dynamic combobox to point to the newly entered record automatically? I thought I might be able to use the following but it didn't seem to work.

Private Sub Form_Close()
Forms!NewOrders!CID.Requery
Forms!NewOrders!CID = me!CID
End Sub

Any Ideas would be great
 
I suspect that by the time your second form gets to run the Close event that Me!CID does not contain what you think it contains.

Try putting the code into the UnLoad event instead.

Another option:-
Do the Requery AFTER you have set the value.



G LS


 
Thanks, the Unload event was the one I needed

I ended up using the following to get it to work

Private Sub Form_Unload(Cancel As Integer)
Forms!NewOrders!CID.Requery
Forms!NewOrders!CID = Forms!Customers!CID
Forms!NewOrders!CID.SetFocus
End Sub

It would not show the new value until I Set the Focus to the Combobox again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top