Import Data via Command Button

  • Thread starter Thread starter Ivan Grozney
  • Start date Start date
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
 
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
 
Back
Top