"Object Required" Error...

doran_doran

Registered User.
Local time
Today, 13:15
Joined
Aug 15, 2002
Messages
349
Sample DB:

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

click on the link and you should see a "Save window", Go ahead and save the sample DB.

can anyone please verify my sql behind a form.

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

Here is my code.
==============================================


Function Query4Data()

Dim strSQL As String
Dim qdfApp As QueryDef

DoCmd.SetWarnings False

Set qdapp = currentdb.QueryDefs("qryIndividual2")

strSQL$ = "Select * " & _
"FROM qryindividual1 " & _
"where(qryindividual1.NewYear = txtYear) And (qryindividual2.Primary_Administrator = cboAdmin);"
qdapp.SQL = strSQL
DoCmd.OpenQuery "qryindividual2"

MyRS.close
qdfApp.close
DoCmd.SetWarnings True

End Function
===========================================

I am getting "Object Required" Error and also it's clearing all the contents in my qryindividual2.

You can open the sample db, then you will know exactly what i am talking about.

Thanks in advance.
Dianna C.
 
I took a look at your database, but the function in there is not the same as the function you posted. Both of the functions seem to have issues, but together they look like they should work. Try using the select and from clauses from above combined with the where clause that was in your database:

where(qryindividual2.Year = # " & Me!txtYear & " # ) And (qryindividual2.Primary_Administrator = Me!cboAdmin);"

Does that work?

GumbyD
 

Users who are viewing this thread

Back
Top Bottom