Can't open a recordset

H

Heapy

I'm trying to run a process that goes as follows:

User opens Form1
User selects an option that opens Form2 which contains some controls
(three check boxes, two text boxes, and two command buttons)
User presses one of the two command buttons on Form2 which causes the
following to take place:
- Three recordsets are to be created and opened, each of which has as
a source a different prestored query.
- The querries being used as a source for the recordsets rely on the
values specified in the checkboxes and texboxes of Form2

Problem: The recordsets won't open.
My Syntax (in Form2) to open the recordsets goes as follows:

Dim rstBilling1 As DAO.Recordset
Set rstBilling1 = CurrentDb.OpenRecordset("qry1", dbOpenDynaset)

.... where "qry1" is the name of a pre-stored query.

The WHERE clause of Query 1's SQL is:

WHERE (((some field)>=[Forms]![Form2]![CheckBox3]) AND ((some
field)>=[Forms]![Form2]![CheckBox1]) AND ((some
field)>=[Forms]![Form2]![CheckBox1]) AND ((some
field)>=[Forms]![Form2]![txtFROM] And (some field)<=[Forms]![Form2]![txtTO])
AND ((some field)=-1) AND ((some field)=False) AND ((some field)=False))
WITH OWNERACCESS OPTION;

----

The code breaks when trying to open the recordset at run-time with an
error3061 (Too Few Parameters. Expected 4).

If I substitute the query being used as the source for another simple query
that just takes records from a table without any criteria the recordset gets
opened. If I remove all criteria that rely on Form2 except for 1, the same
error occurs except that the error msg indicates it expects 1 parameter
instead of 4. This leads me to the conclusion that the values of the Form2's
controls are not being passed to the query.

Why is this happening???

Thx
HWH
 

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