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 / Queries / November 2007

Tip: Looking for answers? Try searching our database.

Make Table Naming Convention

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dawn - 12 Nov 2007 16:05 GMT
When creating a make table query, is it possible to add a parameter value to
the naming syntax in the make table name?

Thanks
Duane Hookom - 12 Nov 2007 16:08 GMT
You can't use a parameter prompt to set or modify the "made" table name. You
could use code to change the SQL property of the saved query.

Signature

Duane Hookom
Microsoft Access MVP

> When creating a make table query, is it possible to add a parameter value to
> the naming syntax in the make table name?
>
> Thanks
fredg - 12 Nov 2007 16:34 GMT
> When creating a make table query, is it possible to add a parameter value to
> the naming syntax in the make table name?
>
> Thanks

Do you mean have the query prompt for the name of the table to make
after the query has already been created?
No, I don't think so.

However, no reason why you can't do it using RunSQL

Dim strTableName as String
strTablename = InputBox("Name of the new table")
DoCmd.RunSQL "Select YourTable.* Into " & strTableName & " From
YourTable;"

or CurrentDb.Execute,

Dim strTableName as String
strTablename = InputBox("Name of the new table")
CurrentDb.Execute "Select YourTable.* Into " & strTableName & " From
YourTable;",dbFailOnError

or even just run the query using the existing table name and then
renaming the table in code:

DoCmdOpenQuery "YourMakeTableQuery"
Dim strTablename as String
strTableName = InputBox("Name of the new Table")
DoCmd.Rename strNewTable , acTable,  "OriginalTablename"

Signature

Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail

Duane Hookom - 12 Nov 2007 17:04 GMT
Good code fred however some users still use spaces in object names :-( You
may need to revise your code to add []s.
Dim strTableName as String
strTablename = InputBox("Name of the new table")
DoCmd.RunSQL "Select YourTable.* Into [" & strTableName & "] From YourTable;"

Signature

Duane Hookom
Microsoft Access MVP

> > When creating a make table query, is it possible to add a parameter value to
> > the naming syntax in the make table name?
[quoted text clipped - 26 lines]
> strTableName = InputBox("Name of the new Table")
> DoCmd.Rename strNewTable , acTable,  "OriginalTablename"
John W. Vinson - 13 Nov 2007 03:03 GMT
>When creating a make table query, is it possible to add a parameter value to
>the naming syntax in the make table name?
>
>Thanks

I see you've gotten good answers but... I'd like to "unask" the question.

In my opinion, MakeTable queries are very rarely necessary at all. Prompting
the user for table names will just add a proliferation of badly-named tables
to your database; and having multiple tables with the same structure is pretty
much always a bad idea in any case!

If you're assuming that you need a table in order to edit or report subsets of
data, your assumption needs revising. You can base a Report or a Form on a
query; you can export from a query; you can do essentially *anything* with a
Query that you can do with a Table. Consider whether you even need these made
tables!

            John W. Vinson [MVP]
 
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.