getting too few parameters on openrecordset

  • Thread starter Thread starter graeme34 via AccessMonster.com
  • Start date Start date
G

graeme34 via AccessMonster.com

Hi I am trying to open a recordset based on an embedded SQL query but when
the code gets to setting the recordset, it is throwing an error out.

strSQL = "SELECT * " _
& "FROM tblSalesOrderLine " _
& "WHERE SalesOrderLine = " & lngOrderNum _
& " AND FullyReceived = False;"

Set rsOrdLine = CurrentDb.OpenRecordset(strSQL, dbOpenDynaset)

I have tyoed the query into the SQL builder and it worked fine there, but
when opening it from the code it is saying it is expecting 1 parameter.

Anybody know why??
 
graeme34 said:
Hi I am trying to open a recordset based on an embedded SQL query but when
the code gets to setting the recordset, it is throwing an error out.

strSQL = "SELECT * " _
& "FROM tblSalesOrderLine " _
& "WHERE SalesOrderLine = " & lngOrderNum _
& " AND FullyReceived = False;"

Set rsOrdLine = CurrentDb.OpenRecordset(strSQL, dbOpenDynaset)

I have tyoed the query into the SQL builder and it worked fine there, but
when opening it from the code it is saying it is expecting 1 parameter.


It sounds like, inspite of its name, the lngOrderNum value
is a text string. Either that or it's a Variant with a Null
value.

To see what is actually being used, place a breakpoint on
the open recordset line and look at what strSQL ro see if
you can determine what's wrong.
 
Hi Marshall

Sorry, my mistake :)
Typing error.....Should have been SalesOrderNumber not SalesOrderLine in
WHERE clause....Thanks anyway!

Marshall said:
Hi I am trying to open a recordset based on an embedded SQL query but when
the code gets to setting the recordset, it is throwing an error out.
[quoted text clipped - 8 lines]
I have tyoed the query into the SQL builder and it worked fine there, but
when opening it from the code it is saying it is expecting 1 parameter.

It sounds like, inspite of its name, the lngOrderNum value
is a text string. Either that or it's a Variant with a Null
value.

To see what is actually being used, place a breakpoint on
the open recordset line and look at what strSQL ro see if
you can determine what's wrong.
 
Back
Top