Hello,
I am trying to basically run the qry below, but every time i run it , it gives me an error saying query must have atleast one destination field. So i went under queries and saw that the TempQry was blank.. I thought that the following code would automatically create a TempQry with the StrSQL qry in it..I am not sure whats wrong with my code. My program is in Access.
I am trying to basically run the qry below, but every time i run it , it gives me an error saying query must have atleast one destination field. So i went under queries and saw that the TempQry was blank.. I thought that the following code would automatically create a TempQry with the StrSQL qry in it..I am not sure whats wrong with my code. My program is in Access.
Code:
Private Sub Findit_Click()
On Error GoTo qry
Dim qdf As QueryDef
Dim StrSQL As String
StrSQL = "SELECT * FROM [PCB Incoming_Production Results] " & _
"WHERE [PCB SS #]= #Me.txtserialno# ORDER BY Date; "
' Create new QueryDef object, don't really need it once the query exists
Set qdf = CurrentDb.CreateQueryDef("TempQry", StrSQL)
' Open query in Datasheet view.
qry:
'if query exists
Set qdf = CurrentDb.QueryDefs("TempQry")
DoCmd.OpenQuery qdf.Name
Set dbs = Nothing
DoCmd.Close acForm, "PCBserialno", acSaveNo
End Sub