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!

Save Unbound Textfield as a Query

Status
Not open for further replies.

mswilson16

Programmer
Nov 20, 2001
243
US
I have a form that makes it possible for users to build Sql statements. @ the minute a just have it so that the results are shown in a list box at the bottom of the form.

What I need is once the SQL statement has been build (on the form) I need it to be saved as a query.

Cheers in advance,

Wilson
 
This should work. Make sure you add the Microsoft DAO library to your code (Tools|References).

Dim mydb As DAO.Database
Dim myquery As DAO.QueryDef

Set mydb = DBEngine(0)(0)
Set myquery = New DAO.QueryDef
myquery.Name = "aname"
myquery.SQL = "the sql statement"
mydb.QueryDefs.Append myquery
mydb.QueryDefs.Refresh
Set myquery = Nothing
Set mydb = Nothing
JHall
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top