Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Laurence,
This macro should work. It uses the "TransferDatabase" function to copy just the table structure with no data into a new table with "1" appended to the name. Then, the old table is deleted and the new table is renamed to remove the "1". Note that this code will run against whatever Access considers to be the "Current" database. Thus, it would be a good idea to close all Access databases you may have open other than the one you wish to run this macro on prior to running it. Hope this helps, Ben Sub CopyTable() Dim strTable As String Dim myDB As Database 'Plug in your table name here strTable = "Table1" 'Now we check if there is a database open On Error Resume Next Set myDB = CurrentDb If myDB Is Nothing Then 'Database not open, so exit MsgBox "Please open the database prior to running macro" Exit Sub End If On Error GoTo 0 'Since everything looks good, we will copy the table structure first DoCmd.TransferDatabase acExport, "Microsoft Access", CurrentDb.Name, _ acTable, strTable, strTable & "1", True 'Now we'll delete the old table DoCmd.DeleteObject acTable, strTable 'Finally, we will now rename the new table to match the old one. DoCmd.Rename strTable, acTable, strTable & "1" End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I create an autonumber similar to Access in Excel? | Excel Programming | |||
Copy Records from Access Database table(more than 5 lakh records in this table) to Excel Sheet | Excel Programming | |||
Access form in Excel Autonumber | Excel Discussion (Misc queries) | |||
Using Excel to change/add/delete records in Access database | Excel Programming | |||
Is it possible to update records in an Access table from Excel? | Excel Programming |