Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / February 2005

Tip: Looking for answers? Try searching our database.

Recordset run time problems

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
TonyB - 25 Feb 2005 10:36 GMT
Hi,
I'm trying out using recordsets for the first time, and I'm having a couple
of problems with the syntax in runtime.
The code is
Dim db As Database
Dim rs As Recordset
Dim sqlstr As String
Set db = CurrentDb
sqlstr = "SELECT * FROM tblQuoteDetails WHERE [quoteID] = tbquoteID"
Set rs = db.OpenRecordset(sqlstr, dbOpenDynaset)

tbQuote is the value of a control on the form calling this vba sub
At this point I get a runtime error 'Too Few parameters, expected 1'

By debugging and assigning tbQuoteID to a test integer variable, I know
tbQuoteID = 5 which is a valid value for the table/field
If I change the sqlstr line to replace tbQuoteID by 5 it runs OK.

Any ideas ?

The other problem I have is that if I use 5 in the openrecordset, and run
further down the sub, I get to a line
       rs!Price = DLookup([Price UK], "tblProductInfo", [ProductID] =
rs!ProductID)

Ths fails with a runtime error 2465, "Access can't find field '|' referred
to in your expression"

From the local window, rs!ProductID has the expected value (1 in this case),
rs!Price is in the recordset as can be seen in the locals window.
[ProductID] is a field in "tblProductInfo" as is [Price UK]

What am I doing wrong here ?
TIA
Tony
Naresh Nichani MVP - 25 Feb 2005 11:24 GMT
Hi:

Try
sqlstr = "SELECT * FROM tblQuoteDetails WHERE [quoteID] = " & tbquoteID

The tbQuoteId should be outside the quotes

Regards,

Naresh Nichani
Microsoft Access MVP

> Hi,
> I'm trying out using recordsets for the first time, and I'm having a couple
[quoted text clipped - 31 lines]
> TIA
> Tony
TonyB - 25 Feb 2005 12:07 GMT
Hi Naresh,
Thanks, I just couldn't see that.
I thought that would fix the other problem as I had got the string wrong
there too. I corrected that and now I have the line
  rs!Price = DLookup("[Price (US)]", "tblProductInfo", "[ProductID] = " &
rs!ProductID)

This now produces the following Run-time error '2001': You cancelled the
previous operation.

rs is the recordset. From the locals window, rs!ProductID has the expected
value (1 in this
case), rs!Price is in the recordset as can be seen in the locals window.
[ProductID] is a field in "tblProductInfo" as is [Price UK]

Is there a conflict between the dlookup function and having a recordset open
? dlookup is operating on different table to the recordset so I can't see
why this should be so !
Can anyone tell me what this means ?
Thanks
Tony

> Hi:
>
[quoted text clipped - 24 lines]
> > TIA
> > Tony
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.