I have 2 tables that list names of locations. I have then built a union query to compile a list of all data that is similar between the 2 tables, which includes things like 'Location Name', 'Location Number', 'Location Type', etc.
In an unbound form, I have a combo box (Combo37) that lists the 'Location Name(s)', and a text box (Location_Number) in which I want to show the location number from the union query based on the name selected in the combo box.
Should be easy, but I can't get either the syntax for a strsql or dlookup code right.
Here is my attmpt at the strsql code:
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strSQL As String
Set db = CurrentDb()
Set qdf = db.QueryDefs("getLocation_Number")
strSQL = "SELECT [qryAllLocations_AllTypes].[Location Number]"
strSQL = strSQL & "FROM [qryAllLocations_AllTypes]"
strSQL = strSQL & "WHERE [qryAllLocations_AllTypes].[Location Name] = '" & Me.Combo37 "'"
qdf.SQL = strSQL
Me.Location_Number.Value = "getLocation_number"
Set db = Nothing
Set qdf = Nothing
I am trying to use the query as my datsource since the form is unbound...? I am sure I have a few things wrong, but would really like to get this strsql stuff down....
Once I get this right, I will then use an append query to save the forms' data to a 3rd table.
Thanks
Kevin
In an unbound form, I have a combo box (Combo37) that lists the 'Location Name(s)', and a text box (Location_Number) in which I want to show the location number from the union query based on the name selected in the combo box.
Should be easy, but I can't get either the syntax for a strsql or dlookup code right.
Here is my attmpt at the strsql code:
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strSQL As String
Set db = CurrentDb()
Set qdf = db.QueryDefs("getLocation_Number")
strSQL = "SELECT [qryAllLocations_AllTypes].[Location Number]"
strSQL = strSQL & "FROM [qryAllLocations_AllTypes]"
strSQL = strSQL & "WHERE [qryAllLocations_AllTypes].[Location Name] = '" & Me.Combo37 "'"
qdf.SQL = strSQL
Me.Location_Number.Value = "getLocation_number"
Set db = Nothing
Set qdf = Nothing
I am trying to use the query as my datsource since the form is unbound...? I am sure I have a few things wrong, but would really like to get this strsql stuff down....
Once I get this right, I will then use an append query to save the forms' data to a 3rd table.
Thanks
Kevin