Can anyone briefly look over the code that I have written for any errors/potential errors. The code seems to be working correctly, but I am not that confident in my vba skills.
Brief explanation:
The form frmLastUpdated will display the last time data was exported. When the user clicks on the OK button, frmLastUpdated's visible property is set to False and function Input_Export_Date is run. The variable Input_Export_Date is a global variable.
Public Function Input_Export_Date()
On Error GoTo Err_Cancel_Exp
Const conErrCancelExp = 13
'Input_Export_Date is a global variable
Input_Export_Date = InputBox("BEGIN EXPORT OF DATA: How far do you wish to go back? (MM/DD/YY)")
'If Input_Export_Date is not null, then make frmLastUpdated visible and then close frmLastUpdated.
'The variable strExp_Date is given the value of Input_Export_Date
If Not IsNull(Input_Export_Date) Then
Forms!frmLastUpdated.Visible = True
DoCmd.Close acForm, "frmLastUpdated"
strExp_Date = Input_Export_Date
End If
'Display date range of data that is about to be exported in message box.
MsgBox "Data from " & strExp_Date & " to " & Date & " is about to be exported to the C:\ drive."
'Run macro that will export data.
DoCmd.RunMacro "Export_All_Macro"
Exit_Input_Export_Date:
Exit Function
Err_Cancel_Exp:
If Err.Number = conErrCancelExp Then
DoCmd.Close acForm, "frmLastUpdated"
MsgBox "Export of data has been canceled:"
Else
MsgBox Err.Description
DoCmd.Close acForm, "frmLastUpdated"
End If
Resume Exit_Input_Export_Date
End Function
I'm not sure if my error code is correct.
If anyone can help, I would greatly appreciate it!
[This message has been edited by crhodus (edited 06-27-2001).]
Brief explanation:
The form frmLastUpdated will display the last time data was exported. When the user clicks on the OK button, frmLastUpdated's visible property is set to False and function Input_Export_Date is run. The variable Input_Export_Date is a global variable.
Public Function Input_Export_Date()
On Error GoTo Err_Cancel_Exp
Const conErrCancelExp = 13
'Input_Export_Date is a global variable
Input_Export_Date = InputBox("BEGIN EXPORT OF DATA: How far do you wish to go back? (MM/DD/YY)")
'If Input_Export_Date is not null, then make frmLastUpdated visible and then close frmLastUpdated.
'The variable strExp_Date is given the value of Input_Export_Date
If Not IsNull(Input_Export_Date) Then
Forms!frmLastUpdated.Visible = True
DoCmd.Close acForm, "frmLastUpdated"
strExp_Date = Input_Export_Date
End If
'Display date range of data that is about to be exported in message box.
MsgBox "Data from " & strExp_Date & " to " & Date & " is about to be exported to the C:\ drive."
'Run macro that will export data.
DoCmd.RunMacro "Export_All_Macro"
Exit_Input_Export_Date:
Exit Function
Err_Cancel_Exp:
If Err.Number = conErrCancelExp Then
DoCmd.Close acForm, "frmLastUpdated"
MsgBox "Export of data has been canceled:"
Else
MsgBox Err.Description
DoCmd.Close acForm, "frmLastUpdated"
End If
Resume Exit_Input_Export_Date
End Function
I'm not sure if my error code is correct.
If anyone can help, I would greatly appreciate it!
[This message has been edited by crhodus (edited 06-27-2001).]