DAO OpenRecordset method

N

nic

Hi There,

I am presently trying to open a query using the DAO
OpenRecordset method which is generating a debug error
saying "Too few parameters expected 2".

the code is provided:

Public Function Develop_missing_form_table()
Dim datab As DAO.Database
Dim rsit As DAO.Recordset

Dim cntr As Long
Dim cntr2 As Long
Dim var_str1 As String
Dim res_str1 As String

Set datab = CurrentDb ' set to the current database
res_str1 = ""

For cntr = 1 To 31
var_str1 = "qry_SUPERVISOR_day" & cntr
Set rsit = datab.OpenRecordset(var_str1,
dbOpenForwardOnly)
res_str1 = rsit.Fields("Field2").Value
If IsNull(res_str1) = True Then
Debug.Print (res_str1)
End If
rsit.Close 'free up the memory
Next cntr


datab.Close 'free up the memory

End Function


Does anybody know how to fix this, I have referenced
queries using this method before yet suddenly now it
doesn't work. Is there another way to do this?

Regards,

-n
 
D

Douglas J. Steele

Are you saying that you can run, for instance, qry_SUPERVISOR_day1 from the
query panel with no problems?
 
V

Van T. Dinh

Your code implies that you have 31 Queries with Query names
""qry_SUPERVISOR_day1", "qry_SUPERVISOR_day2", ...

Is that true?

If that is true, post the SQL String of one of the Queries.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top