I have a form that will run a report to excel based on whether particular check boxes are filled. I am getting an run time error 94. Invalid use of null whith the first selection only. However if I choose all three it works fine and then go back and choose just the first it works as well.
Here is what I have for code I have it simply display a message to error check quickly.
Private Sub cmdStartExport_Click()
Dim DB As Database
Dim xlApp As New Excel.Application
Dim RSBudget As Recordset
Dim WB As Workbook
Dim strFolder As String
Dim strFilename As String
Dim strSheetName As String
Dim introw As Long
Dim strPosition As String
Dim strExportTemplate As String
Dim strStart As String
Dim blnActual As Boolean
Dim blnForecast As Boolean
Dim blnForecast2 As Boolean
Dim qdf As DAO.QueryDef
Dim prm As DAO.Parameter
Dim blnAll As Boolean
Dim blnNR As Boolean
Dim blnCur As Boolean
strStart = txtStart
strFolder = Trim(txtFolder)
If Right(strFolder, 1) <> "\" Then
strFolder = strFolder & "\"
End If
strFilename = Trim(txtFileName)
strFilename = strFolder & strFilename
If Chk1 Then
txtCurrProfile = "Report 1 Complete!"
DoEvents
End If
'blnAll = All(strFolder, strStart, strFilename, WB, xlApp)
If Chk2 Then
txtCurrProfile = "Report 2 Complete!"
DoEvents
End If
'blnNR = NR(strFolder, strStart, strFilename, WB, xlApp)
If Chk3 Then
txtCurrProfile = "Report 3 Complete!"
DoEvents
End If
'blnCur = Cur(strFolder, strStart, strFilename, WB, xlApp)
'txtCurrProfile = "All Reports Complete!"
'DoEvents
End Sub
Here is what I have for code I have it simply display a message to error check quickly.
Private Sub cmdStartExport_Click()
Dim DB As Database
Dim xlApp As New Excel.Application
Dim RSBudget As Recordset
Dim WB As Workbook
Dim strFolder As String
Dim strFilename As String
Dim strSheetName As String
Dim introw As Long
Dim strPosition As String
Dim strExportTemplate As String
Dim strStart As String
Dim blnActual As Boolean
Dim blnForecast As Boolean
Dim blnForecast2 As Boolean
Dim qdf As DAO.QueryDef
Dim prm As DAO.Parameter
Dim blnAll As Boolean
Dim blnNR As Boolean
Dim blnCur As Boolean
strStart = txtStart
strFolder = Trim(txtFolder)
If Right(strFolder, 1) <> "\" Then
strFolder = strFolder & "\"
End If
strFilename = Trim(txtFileName)
strFilename = strFolder & strFilename
If Chk1 Then
txtCurrProfile = "Report 1 Complete!"
DoEvents
End If
'blnAll = All(strFolder, strStart, strFilename, WB, xlApp)
If Chk2 Then
txtCurrProfile = "Report 2 Complete!"
DoEvents
End If
'blnNR = NR(strFolder, strStart, strFilename, WB, xlApp)
If Chk3 Then
txtCurrProfile = "Report 3 Complete!"
DoEvents
End If
'blnCur = Cur(strFolder, strStart, strFilename, WB, xlApp)
'txtCurrProfile = "All Reports Complete!"
'DoEvents
End Sub