Import Data via Command Button

I

Ivan Grozney

I have a user that wants to import data via an ODBC
connection but have it on a cmd button. Can this be done?

tia

Ivan
 
I

Ivan Grozney

To quote Homer Simpson D'OH!!!

I got it working. Here is the code I used (with linking
to the SQL Server and then replacing my current local
table so that the captions wouldn't change) in case anyone
cares...

Dim stQDocName As String
Dim stQ2DocName As String

DoCmd.SetWarnings False

' delete all the data in the tbl_conditions table
stQDocName = "qry_DEL_Conditions"
DoCmd.OpenQuery stQDocName, acNormal, acEdit

DoCmd.TransferDatabase acImport, "ODBC Database", _
"ODBC;DSN=ConditionalSystems;LANGUAGE=us_english;" _
& "DATABASE=ConditionalDB", acTable, "cond", "tbl_CT"

stQ2DocName = "qry_APP_Conditions"
DoCmd.OpenQuery stQ2DocName, acNormal, acEdit

DoCmd.DeleteObject table, "tbl_CT"
DoCmd.SetWarnings True
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top