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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with SQL string!!

Status
Not open for further replies.

rgao

Technical User
Feb 1, 2002
38
CA
Hi, everyone
Right now I need help on sql string.In Access I have a "table1" which has fields named "type"(data type:text),"section"(data type:text) etc
I have some coding:

Dim cnn As ADODB.Connection
Dim rst As New ADODB.Recordset
Dim r As Integer
Set cnn = CurrentProject.Connection
SQL = "select * from table1 where Section='c5'"
rst.Open SQL, cnn, adOpenStatic, adLockReadOnly
r = rst.RecordCount
rst.Close
Set rst = Nothing

every time I run these code I got run time error:method"open" of object"recordset" failed
but if i use another field's name in where clause(where type='A') everything is ok,or if I rename the field name "section" by other name in table, the sql string works well. I just can not use "section" in my SQL string.is it reserved? Thanks for any clues!!

rgao
 
Hi rgao,

Section is a property that is used for forms and reports, you use it to identify a 'section' of a form or report. ie. Header, footer etc...
This is why you are having problems.

Regards,
gkprogrammer
 
You are quite right Section is a reserved work in Access.


There are two ways to write error-free programs; only the third one works.
 
Ooops GKProgrammer beat me to it!!

[smile] There are two ways to write error-free programs; only the third one works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top