getting too few parameters on openrecordset

  • Thread starter graeme34 via AccessMonster.com
  • 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??
 
M

Marshall Barton

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.
 
G

graeme34 via AccessMonster.com

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.
 

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