How to run a query from a comboBox event?

Diango

Registered User.
Local time
Yesterday, 23:01
Joined
Sep 6, 2007
Messages
19
I would like to run a query where I have a comboBox that carries ID's, if I select an ID, then I want to be able to use that selected ID to perform a Select query which will show the results in a textbox.
 
Use the AfterUpdate event of the ComboBox and use a DLookup() function for your query.
 
How do I place that in a TextBox? Is it better to use DLookUP to query a table rather than CurrentDb.Execute?
 
This is the code I have to run that query and it's coming back with an error, something about canceling the previous operation.

Private Sub cmbID_AfterUpdate()
Dim strQuery As String
Dim Value As String

Value = cmbID.Value

strQuery = DLookup("[2007_Term_GPA]", "Undergrad", "ID=" & Value)
End Sub

2007_term_gpa is my column, Undergrad is the name of my table.
 
Weird, I'm still getting the same error.
 
If ID is a string or text field then use the following:
strQuery = DLookup("[2007_Term_GPA]", "Undergrad", "ID='" & Me.cmbID & "'")
If any of the arguments in the DLookup() function are not correct or misspelled then you will get the error you mentioned.
 

Users who are viewing this thread

Back
Top Bottom