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 Chris Miller 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 set a form's recordset with a SQL statement?

Status
Not open for further replies.

steve728

Programmer
Mar 16, 2003
536
US
Instead of using the following:
Me.RecordSource = "GLMaster_Code"
I want to use an SQL statement instead.
is it something like:
Me.RecordSource = "SELECT * FROM table ORDER BY code;" etc.
Please give me a sample of the complete syntax.

I need to get rid of some of the thousands of stored queries I use in my project.

Thank you.

Steve
 
The "something like" you gave is exactly right. Look up the RecordSource property in the help file. It can be the name of a table or query, or can be an SQL statement.

Rick Sprague
Want the best answers? See faq181-2886
To write a program from scratch, first create the universe. - Paraphrased from Albert Einstein
 
Open the query in design-vieuw
open the sql
copy the sql en past it in your recordsource property
 
Thank you all so much! Yes, I frequently use the Query builder. You 've all been so helpful.

Steve
 
Even if you start a form with a table, as soon you use the 3-points-button in the recordset property of that form, Access will ask you if you want to replace the table with a query. Answer yes, and a query design screen will apear where you define what you need. Closing that design query screen, will save the sql stmt in the record set without any definition of a new query. This query designed for that form will not appear in the query tab. Usefull to keep your queries clean.
This work at least for Access 98.

Yvon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top