Restrict import from external DB

W

Wayne-I-M

Hi All

Is it possible to restrict the number of records imported from an external
DB table to an internal table. At the moment the append query has a simple
DateStamp criteria which works fine (the append also writes to another temp
table to give the message box - you are importing # records, etc) - but was
thinking this is a little combersom. Is it possible to restrict the import
itself - maybe not but ... :)


This is the standard code for importing from an external table which I use
quite a bit - as you can see it simply imports all records into a temp table
then via an append writes these to the main table (> timestamp - not shown
here)

Private Sub ButtonName_Click()
Dim IMPfile As TableDef
For Each IMPfile In CurrentDb.TableDefs
If IMPfile.Name = "SomeTempTable" Then
CurrentDb.TableDefs.Delete IMPfile.Name
End If
Next
DoCmd.TransferDatabase acImport, "Path to external DB.mdb", acTable,
"ExternalTableName", "SomeTempTable"
DoCmd.SetWarnings False
DoCmd.OpenQuery "SomeAppendQuery"
DoCmd.SetWarnings True
CurrentDb.TableDefs.Delete "SomeTempTable"
End Sub

Many thanks
 
B

bvt_auto

पपप

Wayne-I-M said:
Hi All

Is it possible to restrict the number of records imported from an external
DB table to an internal table. At the moment the append query has a
simple
table to give the message box - you are importing # records, etc) - but
was
thinking this is a little combersom. Is it possible to restrict the import
itself - maybe not but ... :)


This is the standard code for importing from an external table which I use
quite a bit - as you can see it simply imports all records into a temp
table
then via an append writes these to the main table (> timestamp - not
shown
here)

Private Sub ButtonName_Click()
Dim IMPfile As TableDef
For Each IMPfile In CurrentDb.TableDefs
If IMPfile.Name = "SomeTempTable" Then
CurrentDb.TableDefs.Delete IMPfile.Name
End If
Next
DoCmd.TransferDatabase acImport, "Path to external DB.mdb", acTable,
"ExternalTableName", "SomeTempTable"
DoCmd.SetWarnings False
DoCmd.OpenQuery "SomeAppendQuery"
DoCmd.SetWarnings True
CurrentDb.TableDefs.Delete "SomeTempTable"
End Sub

Many thanks
 

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