filtering a ADO recordset error

  • Thread starter Cathy via AccessMonster.com
  • Start date
C

Cathy via AccessMonster.com

Hi,
I've created an ADO recordset and it appears to work fine. I now want to
filter it to show records for a particular field, i.e. SamplePoint. In the
code below, the message box returns the correct sample point name (e.g. MW-99)
, my stSQL statement looks right ("SELECT * FROM tbl_purgeparameters WHERE
[SamplePoint ] = MW-99"), but I get "Run-time error '-2147217904(8004e10)':
No value given for one or more required parameters" when it hits my RSfile.
Open stSQL, CurrentProject.Connection, adOpenKeyset line.

I'm not sure where to go from here. Please help.

My code is as follows:

Dim cnn As New ADODB.Connection
Dim RSfile As New ADODB.Recordset
Dim stDocName As String
Dim stSQL As String
Dim stSample As String

stDocName = "tbl_purgeparameters"
stSample = Me.SamplePoint
MsgBox "samplepoint is " & Me.SamplePoint

Set cnn = New ADODB.Connection
stSQL = "SELECT * FROM tbl_purgeparameters WHERE [SamplePoint] = " & Me.
SamplePoint
Set RSfile = New ADODB.Recordset
RSfile.Open stSQL, CurrentProject.Connection, adOpenKeyset

Thanks in advance.
Cath
 
B

Brendan Reynolds

String literals need to be enclosed in quotes ...

stSQL = "SELECT * FROM tbl_purgeparameters WHERE [SamplePoint] = '" &
Me.SamplePoint & "'"

That's a single quote followed by a double quote after the "=" sign, and a
single quote between two double quotes at the end.
 
C

Cathy via AccessMonster.com

Thank you very much Brendan.

I'm a happy camper.

Brendan said:
String literals need to be enclosed in quotes ...

stSQL = "SELECT * FROM tbl_purgeparameters WHERE [SamplePoint] = '" &
Me.SamplePoint & "'"

That's a single quote followed by a double quote after the "=" sign, and a
single quote between two double quotes at the end.
Hi,
I've created an ADO recordset and it appears to work fine. I now want to
[quoted text clipped - 33 lines]
Thanks in advance.
Cath
 

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