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!

Make-Take

Status
Not open for further replies.
Sep 21, 2001
28
US
I need to duplicate a table in the same database when a button is clicked. How do I code that? Also, is it possible to use the same default name so the query won't have to ask you for the table name everytime?
 
Set up a recordset object in VBA and try the .Clone method
 
I need more details in how to clone. Is it possible if you post up an example? I am a new beginner in Access.
 
Try this, you can then append the required records to the table. This allows you to specify the name and primary key.


CREATE TABLE ThirdTable (FirstName TEXT, LastName TEXT, SSN INTEGER
CONSTRAINT MyFieldConstraint PRIMARY KEY);


 

You could do this in a the click event of the button.

Dim strSQL As String

'Assume you want to copy the Depts table to DeptsCopy
'Create the SQL statement
strSQL="SELECT Depts.* INTO DeptsCopy FROM Depts;"

'Turn off warning messages
DoCmd.SetWarnings False

'Copy the table by executing the SQL statement
DoCmd.RunSQL (strSQL)

'Turn on warning messages
DoCmd.SetWarnings True
Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top