Select then Append Query

rushilc

New member
Local time
Today, 11:46
Joined
Jun 6, 2013
Messages
8
I have a form which with the push of a button opens a select query. After I have the select query open, is there a way to make a new table with these records directly from the form. I know I can do this by using a "Make Table" query, but I need to make a new table each time, but Access only lets you overwrite the table. Is there anyway you can rename the table each time you run the query in the form itself? I am new to Access, thank you!
 
You could use a button and in the On Click event use an Input Box to get the name of the new table and then run the Make Table query from VBA:

Code:
Dim GetName As String
GetName = InputBox("Please enter new name")
DoCmd.RunSQL "SELECT qryYourQuery.* INTO " & GetName & " FROM qryYourQuery;"
 
Depending on how often you run the new table, you could also automate a datestamp/timestamp being appended to the new table name.

Why are you saving them to a separate table anyway? Seems like overkill, but I don't know your business model.
 
Last edited:
It's for a monthly mailing list, I need to use a select query from the main table and mail people each month. How would you go about making an automated date-stamp onto the table?

Thanks!
 
You can either create a new table for logging or add a field when creating these tables you want:

Code:
Dim GetName As String
GetName = InputBox("Please enter new name")
DoCmd.RunSQL "SELECT qryYourQuery.*, Now() AS TimeStamp INTO " & GetName & " FROM qryYourQuery;"
 
This code gives me the error, "an action query cannot be used as a row source." In your code, the two qryYourQuery is the same correct?
 
You will need to replace qryYourQuery with the same name of the Select query as you stated:

I have a form which with the push of a button opens a select query

but instead of having the form open the Select query, just have it run the code.
 
Also you may want to explore the Format() function, so you can stamp it with 20130607 for example.
 

Users who are viewing this thread

Back
Top Bottom