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

Can I use query name in a SQL String?

Status
Not open for further replies.

rgao

Technical User
Feb 1, 2002
38
CA
Hi, everyone I have a problem in SQL string
I have code like this:

Dim cnn As ADODB.Connection
Dim rs As New ADODB.Recordset
Set cnn = CurrentProject.Connection
SQL = "select * from tableA where Ponum='A5'"
rst.Open SQL, cnn, adOpenStatic, adLockReadOnly
.......

It works well, but if i want to use a Query name (Query6-it has same content as tableA) replace Table name tableA in SQL String:
SQL = "select * from Query6 where Ponum='A5'"
I got run time error, saying "syntax error in from clause"
is Queryname not allowed to use in SQL String?
Thanks for all clues!
rgao
 
Hi,

I believe that querya is within your access? Correct? SQL server will not recognize query but will recognize stored procedures or views.

My question is what are you using the SQL statement with? IS it bound to a control?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top