can anyone verify my sql behind a form

doran_doran

Registered User.
Local time
Today, 04:42
Joined
Aug 15, 2002
Messages
349
You can download the sample database that I am working on. (oh, the link works)

http://www.dbforums.com/attachment.php?postid=3583176

Ok, I am using following version. I don't want to put all the fields in sql (table.field1, table.field2). Instead, I want to feed two field (txtYear and cboAdmin) from the form to the query (qryindividual1 for txtyear and qryindividual2 for cboadmin) and let the query run.

I am using following query but this time i get a error. "The select statement includes a reserve word or an argument name that is mispelled or missing, or the punctuation is incorrect."

Please let me know where is the problem.
Thanks / Dianna


=============================================
Function Query4Data()

Dim strSQL As String
Dim qdfApp As QueryDef

DoCmd.SetWarnings False

Set qdapp = currentdb.QueryDefs("qryIndividual2")

strSQL$ = "Select " & _
"FROM qryindividual2 " & _
"where(qryindividual2.Year = # " & Me!txtYear & " # ) And (qryindividual2.Primary_Administrator = Me!cboAdmin);"
qdapp.SQL = strSQL
DoCmd.OpenQuery "qryindividual2"

MyRS.close
qdfApp.close
DoCmd.SetWarnings True

End Function
==============================================
 
"Object Required" Error

strSQL$ = "Select " & _
"FROM qryindividual2 " & _
"where (qryindividual2.NewYear = #" & Me.txtYear & "#) And (qryindividual2.Primary_Administrator = " & Me.cboAdmin & ");"

Ok, it's now read NewYear. but now i get a different error which is Object Required.

Anyone please help.....
 
You have variables of qdfapp and qdapp. Should these be the same?
 

Users who are viewing this thread

Back
Top Bottom