I am using an unbound control on a form for a user to enter the criteria to search against. I want the one matching record from a table based on the entered criteria and to populate the remaining controls with additional fields in the record. I haven't reached the point of understanding how to use the additional fields yet because I haven't get my select query to work yet.
I am using the code in thread #221226 to execute a select query using a public module. (Included below)
I have verified that the field names in the select statement are an exact match in the table ADInfo. I suspected that the spaces in the field names were the cause of the error however after temporarily removing thiem from the table and the code below I had the same result.
Any insight you can provide is most appreciated. even if this means using a different approach.
EDITED by The_Doc_Man to correct code tags; no other edits made. 4/20/22
I am using the code in thread #221226 to execute a select query using a public module. (Included below)
Code:
Public Sub QDef(strSql As String)
Dim db As DAO.Database
Dim qdfTemp As QueryDef
Dim strSeason As String
Dim strDocName As String
Set db = CurrentDb
strDocName = "qryQueries"
db.QueryDefs.Delete strDocName
Set qdfTemp = db.CreateQueryDef("qryQueries")
qdfTemp.SQL = strSql
DoCmd.OpenQuery strDocName
End Sub
I have verified that the field names in the select statement are an exact match in the table ADInfo. I suspected that the spaces in the field names were the cause of the error however after temporarily removing thiem from the table and the code below I had the same result.
Any insight you can provide is most appreciated. even if this means using a different approach.
Code:
User = [Forms]![Users].[Form]![txtSearchString]
qryUser = "Select [Display Name] From ADInfo WHERE [User Name]='" + User + "';"
EDITED by The_Doc_Man to correct code tags; no other edits made. 4/20/22
Last edited by a moderator: