Why am I getting a run time error?

A

Al

The following code breaks on the last line and generates a run time error:
*********************************
Dim ADOcnncvp As ADODB.Connection
Dim ADOrstcvp As ADODB.Recordset
Dim sqlcvp As String

Set ADOcnncvp = CurrentProject.Connection
Set ADOrstcvp = New ADODB.Recordset

sqlcvp = "SELECT PatientID, Section, SectionSignDate, SectionVerfDate
from tblCRFSectionsLog WHERE PatientID='.' AND Section = 'Cover Page'"

ADOrstcvp.Open sqlcvp, ADOcnncvp, 3, 2
*************************************
message:
Run time error:
Method 'Open' of Object '_Recordset' failed

I could not find help on this message. Any Idea?
thanks
 
K

kingston via AccessMonster.com

Instead of:
Dim ADOrstcvp As ADODB.Recordset

Try:
Dim ADOrstcvp As New ADODB.Recordset
Without:
Set ADOrstcvp = New ADODB.Recordset

Also, verify your query string. Make it a simple SELECT statement that you
know will work.
 

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