andy_dyer
Registered User.
- Local time
- Today, 05:30
- Joined
- Jul 2, 2003
- Messages
- 806
Ok...
I've found literally hundreds of posts both on this forum and on others but none appear to give me pointers for what I want to be able to do...
I have three Excel files
Task Import.xls
Data Import.xls
Project Import.xls
I have also three Access tables
tblTask
tblData
tblProject
The Excel files have headings and at present because only I has access to the tables I have to manually right click import and browse to the files (they are always in the same location) then click next, next, next, next, next and then type in the same table name as it currently exists and then click yes to overwrite...
It seems crazy because there are no options that need changing that I can't find a way of doing this either one at a time or all together preferbaly using vba or at worst a macro...
Here is where I am with one table - this deletes the current table then imports under the same table name but continues the auto numbering on the Primary Key - can I get this to reset somehow? And then do i just repeat the code for the other files or is there a better way??
Thanks everyone for looking!!
I've found literally hundreds of posts both on this forum and on others but none appear to give me pointers for what I want to be able to do...
I have three Excel files
Task Import.xls
Data Import.xls
Project Import.xls
I have also three Access tables
tblTask
tblData
tblProject
The Excel files have headings and at present because only I has access to the tables I have to manually right click import and browse to the files (they are always in the same location) then click next, next, next, next, next and then type in the same table name as it currently exists and then click yes to overwrite...
It seems crazy because there are no options that need changing that I can't find a way of doing this either one at a time or all together preferbaly using vba or at worst a macro...
Here is where I am with one table - this deletes the current table then imports under the same table name but continues the auto numbering on the Primary Key - can I get this to reset somehow? And then do i just repeat the code for the other files or is there a better way??
Code:
Private Sub cmdImport_Click()
Dim msg As String, button As Variant, title As String, response As Variant
msg = "Is the updated file Task Import placed in 'Z:\PM Metrics\Task Import.xls'?"
button = vbYesNo + vbDefaultButton2
title = "File Location Checkpoint"
response = MsgBox(msg, button, title)
If response = vbYes Then
'Delete old records from tbltask
DoCmd.SetWarnings False
DoCmd.RunSQL "Delete [tblTask].* from [tblTask]"
DoCmd.SetWarnings True
'Import new records from Excel file into tblTask
DoCmd.TransferSpreadsheet acImport, 8, "tblTask", "Z:\PM Metrics\Task Import.xls", True, ""
Else
DoCmd.OpenForm "frmmenu"
End If
End Sub
Thanks everyone for looking!!
Last edited: