Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RunTime Error 424

Status
Not open for further replies.

pkw25

MIS
Mar 20, 2002
46
IE
I get a Runtime Error 424 on this piece of code when using SQL to query the database. It fails at the rs.open line. Any Ideas?
For some reason SQL queries work fine on another similar databse on the same machine.

Private Sub Form_Load()
On Error GoTo Err_Form_Load

Dim rs As Recordset
Dim strSELECT As String

Set rs = CreateObject("ADODB.Recordset")
strSELECT = "SELECT * From tblSITUATION where ID ='16';"

rs.Open strSELECT, "DBPSY CBT", adOpenKeyset

MsgBox rs("REVISED"), 16, "IMPORTANT STATEMENT PLEASE READ"

rs.Close
Set rs = Nothing

Exit_Form_Load:
Exit Sub

Err_Form_Load:
MsgBox Err.DESCRIPTION
' MsgBox Raise.Number
Resume Exit_Form_Load

End Sub
 
You need a connection object somewhere in you rs.Open line.
rs.open strselect,connection,cursor type, lock type
using ado.
 
"DBPSY CBT" doesn't look like a valid ADO connection string.

[small]On two occasions I have been asked, "Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?" I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. (Charles Babbage)[/small]
 

Thanks for you reply

I don't think it's the connection string since it works ok using the following code. "DBPSY CBT" is a valid ODBC Connection.

Private Sub Command29_Click()

Dim rs As Recordset
Dim strSELECT As String

Set rs = CreateObject("ADODB.Recordset")
rs.Open "tblSITUATION", "DBPSY CBT", adOpenKeyset
rs.Move 13

MsgBox rs("REVISED")

rs.Close
Set rs = Nothing
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top