"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)