In my database I have this simple form:
Its purpose is to import an excel spreadsheet into a specific table in my database. There are two separate ones because the spreadsheets come in two types. So each one accepts a spreadsheet with specific column headers that match the tables they get imported to. This is its underlying vba code:
Code:
Option Compare Database
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
Private Sub btnImportSpreadsheet_Click()
Dim FSO As New FileSystemObject
' Edit upcoming lines for what table data goes to
If FSO.FileExists(Me.txtFileName) Then
ExcelImport.ImportExcelSpreadsheet Me.txtFileName, "StuDB_Source"
Else
MsgBox "File not found"
End If
End Sub
Private Sub btnBrowse1_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.txtFileName1 = item
Next
End If
End Sub
Private Sub btnImportSpreadsheet1_Click()
Dim FSO As New FileSystemObject
' Edit upcoming lines for what table data goes to
If FSO.FileExists(Me.txtFileName) Then
ExcelImport.ImportExcelSpreadsheet Me.txtFileName, "Majors_Source"
Else
MsgBox "File not found"
End If
End Sub
This code has been working for me for about a month with no errors, now all of a sudden I get this Invalid use of null error when I try to import on the second import option.
The first import option still works but whats weird is that now if I import with the first option then try to import with the second option I get this error:
So its as if now the second option's code is somehow pulling its source file from the first option, which it has never done before.
And if I use the second option with the first option I get the invalid use of null:
So my thought is that somehow the vba is messed up. If anyone knows how to get around this I would greatly appreciate the help, I'm drawing blank here