PC Review


Reply
Thread Tools Rate Thread

Create Recordset in VBA

 
 
George
Guest
Posts: n/a
 
      25th Sep 2008
I've got a form called XYZ that has a record ID in one of the fields,
[BKWakeREID],on the form. I want to open a related database, called GES,
and create a temp recordset from GES using the following code. The XYZ form
is open and the following code is executed under a command button click sub.
The control named BKWakeREID contains the pointer to the records in GES.

Dim RS As DAO.Recordset, myCaseID As String, db As DAO.Database
Dim stDocName As String, stLinkCriteria As String, mySQL As String
Set db = CurrentDb()
mySQL = "SELECT GES.* FROM GES WHERE GES.Account = me![BKWakeREID]"
Set RS = DBEngine(0)(0).OpenRecordset (mySQL, dbOpenDynaset)

I'm getting an error when I execute the openrecordset command of "Too few
parameters, Expected 1"

Could someone suggest the correct syntax to fix this?


 
Reply With Quote
 
 
 
 
Dirk Goldgar
Guest
Posts: n/a
 
      25th Sep 2008
"George" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I've got a form called XYZ that has a record ID in one of the fields,
> [BKWakeREID],on the form. I want to open a related database, called GES,
> and create a temp recordset from GES using the following code. The XYZ
> form is open and the following code is executed under a command button
> click sub. The control named BKWakeREID contains the pointer to the
> records in GES.
>
> Dim RS As DAO.Recordset, myCaseID As String, db As DAO.Database
> Dim stDocName As String, stLinkCriteria As String, mySQL As String
> Set db = CurrentDb()
> mySQL = "SELECT GES.* FROM GES WHERE GES.Account = me![BKWakeREID]"
> Set RS = DBEngine(0)(0).OpenRecordset (mySQL, dbOpenDynaset)
>
> I'm getting an error when I execute the openrecordset command of "Too few
> parameters, Expected 1"
>
> Could someone suggest the correct syntax to fix this?



You need to take me![BKWakeREID] out of the string, and just append its
value on the end:

mySQL = "SELECT GES.* FROM GES WHERE GES.Account = " & Me![BKWakeREID]

If Account is a text field, you'll also need to embed quotes around the
value:

mySQL = "SELECT GES.* FROM GES WHERE GES.Account = '" & _
Me![BKWakeREID] & "'"


--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DAO Create recordset from recordset =?Utf-8?B?bWRhaXNs?= Microsoft Access VBA Modules 2 20th Jun 2006 09:07 PM
Could create a new recordset based an exist recordset via SQL directly Jason Jiang Microsoft Access 13 21st Apr 2006 03:25 AM
create query def and create recordset.. help =?Utf-8?B?U01BMDA3?= Microsoft Access Getting Started 3 2nd Mar 2006 06:12 PM
Create a recordset =?Utf-8?B?YVdz?= Microsoft Access VBA Modules 3 7th Oct 2005 03:57 PM
Create a recordset from a recordset Gerry Goldberg Microsoft Access Queries 1 13th Nov 2003 11:02 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:35 AM.