Help with Opening ADODB.Recordset

G

Guest

I'm trying to open a table which contains a password using the
ADODB.Recordset feature. For some reason the following code comes back with
the error - (Run-time error -'2137217900 (80040e14)' Invalid SQL Statement;
expected DELETE, INSERT or UPDATE.):

Dim rstPassword As New ADODB.Recordset
Dim con As New ADODB.Connection
Dim stPassword As String
Dim ccn As New ADODB.Connection
Set ccn = CurrentProject.Connection

rstPassword.Open "tbl Password", ccn, adOpenKeyset, adLockOptimistic

"tbl Password" is a table in the database. Any help is appreciated
 
R

RoyVidar

JR_06062005 wrote in message
I'm trying to open a table which contains a password using the
ADODB.Recordset feature. For some reason the following code comes back with
the error - (Run-time error -'2137217900 (80040e14)' Invalid SQL Statement;
expected DELETE, INSERT or UPDATE.):

Dim rstPassword As New ADODB.Recordset
Dim con As New ADODB.Connection
Dim stPassword As String
Dim ccn As New ADODB.Connection
Set ccn = CurrentProject.Connection

rstPassword.Open "tbl Password", ccn, adOpenKeyset, adLockOptimistic

"tbl Password" is a table in the database. Any help is appreciated

Try specifying a commandtypeenum

rstPassword.Open _
"tbl Password", ccn, adOpenKeyset, adLockOptimistic, adcmdtable
 
G

Guest

I think I've discovered the problem. The table name (for some reason) cannot
have a space in it. When I use the same code with the table renamed to
"tblPassword", it works. Your suggestion may get around this problem, but
I'm not sure what a commandtypeenum is.
 
D

Douglas J Steele

Actually, putting square brackets around it should have solved the problem,
but not having spaces is strongly recommended.

rstPassword.Open "[tbl Password]", ccn, adOpenKeyset, adLockOptimistic
 

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