I'm trying to have access look out to a file (file name could change) then UPDATE and if not in the table ADD the information from the spreadsheet Tab ATT to the ATTORNEY table. Right now I'm struggling just to get the file to import into Access. I've created an excel file with a Tab named ATT and want it to upload in order to update and add the information to the table called ATTORNEY. The original spreadsheet (tab ATT) will grow in rows/records...
'This part of the code works (using a browser I select the file I want to use)
Private Sub btnBrowse_Click()
Dim diag As Office.FileDialog
Dim item As Variant
Set diag = Application.FileDialog(msoFileDialogFilePicker)
diag.AllowMultiSelect = False
diag.Title = "Please select an Excel Spreadsheet"
diag.Filters.Clear
diag.Filters.Add "Excel Spreadsheets", "*.xls, *.xlsx"
If diag.Show Then
For Each item In diag.SelectedItems
Me.txtfilename = item
Next
End If
End Sub
-----------------------------------------------------
'THIS IS WHERE THE PROGRAM STOPS.
Private Sub btnImportAtt_Click()
Dim FSO As New FileSystemObject
If FSO.FileExists(Me.txtfilename) Then
ExcelImport.ImportExcelSpreadsheet Me.txtfilename, FSO.GetFileName(Me.txtfilename) 'get a compile error: variable not defined"
End If
End Sub
Course the next step is once the table is imported to update and add records to the Attorney table. Can you do both or will I need to create separate code to run Update and another to add query?
Thank you for your support
'This part of the code works (using a browser I select the file I want to use)
Private Sub btnBrowse_Click()
Dim diag As Office.FileDialog
Dim item As Variant
Set diag = Application.FileDialog(msoFileDialogFilePicker)
diag.AllowMultiSelect = False
diag.Title = "Please select an Excel Spreadsheet"
diag.Filters.Clear
diag.Filters.Add "Excel Spreadsheets", "*.xls, *.xlsx"
If diag.Show Then
For Each item In diag.SelectedItems
Me.txtfilename = item
Next
End If
End Sub
-----------------------------------------------------
'THIS IS WHERE THE PROGRAM STOPS.
Private Sub btnImportAtt_Click()
Dim FSO As New FileSystemObject
If FSO.FileExists(Me.txtfilename) Then
ExcelImport.ImportExcelSpreadsheet Me.txtfilename, FSO.GetFileName(Me.txtfilename) 'get a compile error: variable not defined"
End If
End Sub
Course the next step is once the table is imported to update and add records to the Attorney table. Can you do both or will I need to create separate code to run Update and another to add query?
Thank you for your support