Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / January 2006

Tip: Looking for answers? Try searching our database.

Use VBA to Create a Select Query

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
richardb - 04 Jan 2006 16:22 GMT
Can someone please help me find (or provide) an example of using VBA in a
module to create a Select Query. I tried searching for this in on-line help
and Microsoft.Com. Right now I can put new sql text into an existing query
(myq.SQL = sqltext), but need to 1) create the query; 2) delete the query
after it has been used. Thank you.
Roger Carlson - 04 Jan 2006 16:31 GMT
On my website (www.rogersaccesslibrary.com), is a small Access database
sample called "CreateQueries2.mdb" which illustrates how to do this.

Signature

--Roger Carlson
 Access Database Samples: www.rogersaccesslibrary.com
 Want answers to your Access questions in your Email?
 Free subscription:
 http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L

> Can someone please help me find (or provide) an example of using VBA in a
> module to create a Select Query. I tried searching for this in on-line help
> and Microsoft.Com. Right now I can put new sql text into an existing query
> (myq.SQL = sqltext), but need to 1) create the query; 2) delete the query
> after it has been used. Thank you.
richardb - 04 Jan 2006 17:20 GMT
Thank you Roger. Your example was complete. Now I need similar help to create
a new table (and delete the table). This operation can make a copy of a
"model" table. I looked at your "Create Table from Linked 2K" but could not
pull out the answer to my basic question. Any further references? Thanks.

> On my website (www.rogersaccesslibrary.com), is a small Access database
> sample called "CreateQueries2.mdb" which illustrates how to do this.
[quoted text clipped - 5 lines]
> > (myq.SQL = sqltext), but need to 1) create the query; 2) delete the query
> > after it has been used. Thank you.
Roger Carlson - 04 Jan 2006 17:27 GMT
Sure.  Look for a sample called "DAO.mdb".  This is not quite as polished,
but I used it in my database implementation classes.  Look at Modules
"Class11" and "Class13".  Class11 shows how to create tables with DAO.
Class 13 shows how to do the same thing with SQL data definition statements.
Personally, I prefer SQL.

Let me know if you have any questions.

Signature

--Roger Carlson
 Access Database Samples: www.rogersaccesslibrary.com
 Want answers to your Access questions in your Email?
 Free subscription:
 http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L

> Thank you Roger. Your example was complete. Now I need similar help to create
> a new table (and delete the table). This operation can make a copy of a
[quoted text clipped - 10 lines]
> > > (myq.SQL = sqltext), but need to 1) create the query; 2) delete the query
> > > after it has been used. Thank you.
richardb - 04 Jan 2006 18:10 GMT
Thanks again Roger. I see that "db.TableDefs.Append tblNew" is not required
with the SQL method. I am now reviewing the SQL Constraint clauses in an MS
Language Reference and in your example. I believe I've got this, but am
always frustrated by the absence of an example or two in the MS docs. many
thanks. I've bookmarked your helpful site.

> Sure.  Look for a sample called "DAO.mdb".  This is not quite as polished,
> but I used it in my database implementation classes.  Look at Modules
[quoted text clipped - 23 lines]
> query
> > > > after it has been used. Thank you.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.