I've been using queries in VBA for a while and usually have a pretty good handle on them, but this one is kicking my butt. Using Access 2007.
The form is designed to export(append) records from tables in the current database to identical tables in another database.
I know the loop is working because the table names are printed to the immediate window, but when I check the database being appended to the information isn't there. I am also not recieving any error messages; I'm stumped.
Pretty straight forward:
where txtto and txtfrom are textboxes
Thanks in advance
The form is designed to export(append) records from tables in the current database to identical tables in another database.
I know the loop is working because the table names are printed to the immediate window, but when I check the database being appended to the information isn't there. I am also not recieving any error messages; I'm stumped.
Pretty straight forward:
where txtto and txtfrom are textboxes
Code:
Private Sub cmdimport_Click()
Dim i As Integer
Dim fromdb As String
Dim todb As String
On Error Resume Next
todb = Me.txtto
fromdb = Me.txtfrom
Set Db = OpenDatabase(fromdb)
For i = 0 To Db.TableDefs.Count - 1
If Mid(Db.TableDefs(i).Name, 1, 4) <> "MSys" Or "USys" Then
DoCmd.RunSQL "INSERT INTO Db.TableDefs(i).Name IN fromdb SELECT AVSTATS.* FROM Db.TableDefs(i).Name);"
Debug.Print Db.TableDefs(i).Name
End If
Next
End Sub
Comment