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

Drop Table in SQL database from access 1

Status
Not open for further replies.

ph74

Technical User
Aug 2, 2001
19
0
0
GB
I have a
Code:
DoCmd.TransferDatabase
which sucessfully copies a table from my Access DB to an SQL DB BUT only the first time. After checking other posts i need to add a
Code:
DROP TABLE
before the export.

How do you drop a table from an SQL DB from within Access??
 
Thanks for the quick reply John.
This returns a
Code:
Table 'StaffExport' does not exist
The table is not is the local Access DB but rather in an SQL DB, so some how need to reference the ODBC connection??
 
You could use ADO
Code:
Dim con as ADODB.COnnection

set con = New ADODB.Connection

with con
    .Open "DSN=mySystemDSN;" & _ 
          "Uid=myUsername;" & _ 
          "Pwd=myPassword"
    .Execute "DROP TABLE StaffExport"
end with

set con = Nothing
You would need a reference to ADO though.
 
Thanks nicsin, this looks like what i need, but could you expand a bit on "You would need a reference to ADO though."
 
You have to add a reference to ADO in your project. Just go to menu Tools -> References and check the Microsoft ActiveX Data Objects Library. Then you will be able to construct the ADO connection object and perform the task.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top