saving the data in the spreadsheet into a table

A

Anakin Moonwalker

I have a table (named Table1) that has duplicate entries.
I then made a query that gets the unique entries of this table.

When I run:

Private Sub Command1_Click()
DoCmd.OpenQuery "Get_Unique_Entries"
End Sub

....the unique contents of Table1 get displayed in Spreadsheet View.

What do I need to add in the code above so that the contents that just got
displayed in Spreadsheet View get saved into another table (named Table2)?
 
J

JackP

change the query type to be an APPEND query, using table2.

you'll be warned yes/no to continue when you run it. If you want to avoid
this, change the code to

Private Sub Command1_Click()
DoCmd.SetWarnings False 'switch off warning message
DoCmd.OpenQuery "Get_Unique_Entries"
DoCmd.SetWardnings True 'switch warnings back on again
End Sub
 
A

Anakin Moonwalker

I'm sorry, but I'm a real beginner. How do I change the query type to be an
APPEND query?
 
J

JackP

No problem...
open the query in DESIGN view.
from the 'Query' menu at the top, you will notice 'select query' is
highlighted.
Change this to append query.

You will need to specify the table name you wish to append to. You will also
need to specify which fields to append to (you get a new row called "append
to" which is a dropdown showing the fields in the table you selected).
 
D

Douglas J Steele

With your query open in Design mode, look at the Query menu on the menu bar.
If table2 already exists, you'll want to select Append query. If table2
doesn't exist, select Make-table Query. Fill in the table details in the new
dialog that appears, and you're done.
 
Top