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

How do I create a query in code? 1

Status
Not open for further replies.

mmartinez74

Technical User
Nov 20, 2002
9
US
Assuming that I have a table called: tbl_Clients
and that I want to create a query that selects all records from tbl_Clients and save it as myQueryClients.
All of this will run as a routine.

How could I do that?
 
A.[tab]It is a BAD idea, it would just duplicate existing information. So, I ASS-U-ME this is just a 'test' to see the generic process?

B.[tab]ASS=U-ME (ing) the response to "A" is at least a qualified yes, you just build the qusey string as it would appear most anywhere ...

strSql = "Select * from tbl_Clients;" (just as a "Select" query) OR

strSql = "Select * into MyCustTable Form tbl_Clients;"

Tnen (for the latter)

DoCmd.RunSql strSql

There are so many variations of this I will not even start to try mention them.

AND, the subj is pretty well covered in Ms. A. "Help".

MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
When I run the query, I get the following error: Query input must contain at least one table or query.

I asked the question to try and understand a concept, what I am trying to do is generate a query in code that will create a copy of a table into an archive table which will include the day's date as part of it's name. It is part of a backup routine that I am working on.
 
Nevermind...I found the problem was with a syntax error in my code...thanks a bunch!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top