Lobster1071
Registered User.
- Local time
- Today, 00:48
- Joined
- May 18, 2008
- Messages
- 23
I'm trying to find an elegant solution to an import issue using the TransferDatabase command (Access 2007). I haven't found a good solution yet, and have read a few posts, including a couple from this site related to this issue. If someone could point me to a link with a good solution, I would appreciate it.
Here is the issue...I have a project with a "table free" frontend main program, with linked tables to the backend containing the actual tables. There is a button that the user presses to import various DBF file(s). When the TransferDatabase command is run, it has no append option that I am aware of, so a table is created each time this happens. Yes, I have code to delete the existing "temp" table so that a new one can be created with the desired name, but the table is created in the frontend, and not the backend,which is where I would like it to be if no append option exists.
This is not a major issue, I'm just trying to find a way to make it "cleaner" if possible. This means the frontend database, over time, will continue to grow due to this temp import file being created and deleted for each import, and it will need to be compacted. I already even created two automatic routines to compact and repair the backend AND the frontend databases if each exceeds a certain file size.
I'm not going to bore everyone with all the code, but I have a function to check if the import table "TempX" exists, then delete it if it does, this way I don't get TempX1, TempX2, etc because the TransferDatabase command doesn't overwrite the table if it exists, but creates a new one with a number at the end
If TableExists("TempX") Then
DoCmd.DeleteObject acTable, "TempX"
End If
DoCmd.TransferDatabase acImport, "dBase IV", GrabDir(.SelectedItems.Item(1)), acTable, GrabFile(.SelectedItems.Item(1)), "TempX", False
Everything works fine, except as I've said, the TempX table is created in the frontend database. A simple append option in the TransferDatabase would solve everything, because I can then append the imported data into a linked table in the backend, but don't see how it can be done. I just would love it if there were a way to import a DBF file into a program without actually having to create a new table every time.
Any good solutions out there?
Thanks
Here is the issue...I have a project with a "table free" frontend main program, with linked tables to the backend containing the actual tables. There is a button that the user presses to import various DBF file(s). When the TransferDatabase command is run, it has no append option that I am aware of, so a table is created each time this happens. Yes, I have code to delete the existing "temp" table so that a new one can be created with the desired name, but the table is created in the frontend, and not the backend,which is where I would like it to be if no append option exists.
This is not a major issue, I'm just trying to find a way to make it "cleaner" if possible. This means the frontend database, over time, will continue to grow due to this temp import file being created and deleted for each import, and it will need to be compacted. I already even created two automatic routines to compact and repair the backend AND the frontend databases if each exceeds a certain file size.
I'm not going to bore everyone with all the code, but I have a function to check if the import table "TempX" exists, then delete it if it does, this way I don't get TempX1, TempX2, etc because the TransferDatabase command doesn't overwrite the table if it exists, but creates a new one with a number at the end
If TableExists("TempX") Then
DoCmd.DeleteObject acTable, "TempX"
End If
DoCmd.TransferDatabase acImport, "dBase IV", GrabDir(.SelectedItems.Item(1)), acTable, GrabFile(.SelectedItems.Item(1)), "TempX", False
Everything works fine, except as I've said, the TempX table is created in the frontend database. A simple append option in the TransferDatabase would solve everything, because I can then append the imported data into a linked table in the backend, but don't see how it can be done. I just would love it if there were a way to import a DBF file into a program without actually having to create a new table every time.
Any good solutions out there?
Thanks