querydef execute error: expected function

stormin_norm

Registered User.
Local time
Today, 11:21
Joined
Apr 23, 2003
Messages
213
All I want to do is run a make table query (or append) and show the user how many records were processed.
If I try to set recordset equal to the qdf.Execute I get the Compile error "Expected Function or variable".


I'm not sure what I'm missing...I've searched numerous threads and tried various combos of the execute method.

strquery = "qryEmailGenerate"
Set db = CurrentDb
Set qdf = db.QueryDefs(strquery)
Set rs = qdf.Execute
txtStatus = "Number of email recs: " & rs.RecordCount & vbCrLf
 
Last edited:
Hi -

Try this:
Code:
 strQuery = "qryEmailGenerate"
 Set db = CurrentDb
 Set qdf = db.QueryDefs(strQuery)

 qdf.Execute

 txtStatus = "Number of email recs: " & qdf.RecordsAffected & vbCrLf

hth,

- g
 
Thanks Gromit! 'Dats da ticket!

Made a slight mod to first clear out the table then execute the append query. (I changed from a maketable to an append query so I don't have to check if the table exists before deleting it.)

Also added a parameter because the query has a filter using a form's field.
(Error 3061 Too few paramters)

works great! :D
Code:
DoCmd.SetWarnings False
DoCmd.RunSQL "Delete Email.* from Email;"
DoCmd.SetWarnings True

    Set qdf = db.QueryDefs("Email0101 Gen")
    qdf.Parameters("Enter Term") = Me.choose_term
    qdf.Execute
    txtStatus = "Number of 0101 recs: " & qdf.RecordsAffected & vbCrLf
 

Users who are viewing this thread

Back
Top Bottom