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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If not exist 1

Status
Not open for further replies.

samotek

Technical User
May 9, 2005
197
BG
I want to copy a table only when the copied table does not exist. How can i do it ?

DoCmd.TransferDatabase acImport, "Microsoft Access", CurrentDb.Name, acTable, "Table1", "CopyOfTable1", True
 
You can DLookup the system table MSysObjects.

 
A starting point:
Code:
strTable = "CopyOfTable1"
blnExists = False
For Each t In CurrentData.AllTables
  If t.Name = strTable Then
    blnExists = True
    Exit For
  End If
Next
If Not blnExists Then
  DoCmd.TransferDatabase acImport, "Microsoft Access", CurrentDb.Name, acTable, "Table1", strTable, True
End If

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top