Help with code to run query and test a field in the record

  • Thread starter Thread starter Kate
  • Start date Start date
K

Kate

Tried the following and get the message too few parameters
expected 3. The following statement gets highlighted:

Set rs = db.OpenRecordset("QueryAv")

Any idea? Thanks


Dim db As DAO.Database
Dim rs As DAO.Recordset

Set db = CurrentDb()
Set rs = db.OpenRecordset("QueryAv")

If rs![Booking ID] = 1 Then
DoCmd.OpenForm "SINGLE BOOKING DETAIL"
End If

rs.Close : Set rs = Nothing
Set db = Nothing
 
Post the SQL String of your QueryAv.

Do you use Parameters in this Query?

If you do, you need to resolve the Parameters before passing to JET for
processing.

--
HTH
Van T. Dinh
MVP (Access)


Kate said:
Tried the following and get the message too few parameters
expected 3. The following statement gets highlighted:

Set rs = db.OpenRecordset("QueryAv")

Any idea? Thanks


Dim db As DAO.Database
Dim rs As DAO.Recordset

Set db = CurrentDb()
Set rs = db.OpenRecordset("QueryAv")

If rs![Booking ID] = 1 Then
DoCmd.OpenForm "SINGLE BOOKING DETAIL"
End If

rs.Close : Set rs = Nothing
Set db = Nothing

MVP [MS Access]
 
hi Van.
Kate did post the SQL, in a separate thread 3:59 pm this date, subject line:
I'm struggling with my limited knowledge of code.
i posted an answer, but maybe you'll come up with something better on
looking at it?
tina :)


Van T. Dinh said:
Post the SQL String of your QueryAv.

Do you use Parameters in this Query?

If you do, you need to resolve the Parameters before passing to JET for
processing.

--
HTH
Van T. Dinh
MVP (Access)


Kate said:
Tried the following and get the message too few parameters
expected 3. The following statement gets highlighted:

Set rs = db.OpenRecordset("QueryAv")

Any idea? Thanks


Dim db As DAO.Database
Dim rs As DAO.Recordset

Set db = CurrentDb()
Set rs = db.OpenRecordset("QueryAv")

If rs![Booking ID] = 1 Then
DoCmd.OpenForm "SINGLE BOOKING DETAIL"
End If

rs.Close : Set rs = Nothing
Set db = Nothing

MVP [MS Access]
 
Yes.

There are 3 Parameters that need to be resolved before passing the SQL
String to JET for processing. They are:

Forms![SINGLE BOOKING AVAILABILITY]!BookingDate
Forms![SINGLE BOOKING AVAILABILITY]!Combo8
Forms![SINGLE BOOKING AVAILABILITY]!Combo10

Note that JET Database Engine which process the SQL String does not know
anything about Forms or Controls on Form so these need to be replaced with
actual values before passing the SQL String to JET for processing.
 
Back
Top