jeran042
Registered User.
- Local time
- Today, 13:51
- Joined
- Jun 26, 2017
- Messages
- 127
Let me start by saying this procedure works the way I intend.
My question is more of efficiency/elegance. Based on the code below, is this the most efficient way to accomplish this?
Any suggestions/edit welcome, and thank you
My question is more of efficiency/elegance. Based on the code below, is this the most efficient way to accomplish this?
Code:
Private Sub cmdDAILY_Click()
'Import the daily file from the "PARSE_" file
'Error handling
On Error GoTo Error_Handler
Dim iResponse As Integer
If MsgBox("This action will IMPORT the Daily file, " & vbNewLine & _
"Do you want to Continue? ", vbYesNo + vbQuestion, "WARNING") = vbNo Then Exit Sub
'Test to make sure that the daily records were not already appended
If FormatDateTime(DMax("[PAY-DATE]", "qryTEMP_MONTH_TO_DATE"), vbShortDate) <> Date Then
DoCmd.RunSavedImportExport "Append to ""TBL_MONTH_TO_DATE"" TABLE"
DoCmd.OpenReport "RPT: ACCOUNTS - DO NOT USE_MONTH_TO_DATE", acViewReport, "", "", acNormal
DoCmd.OpenReport "RPT: TEMP_MONTH_TO_DATE_DAILY", acViewReport, "", "", acNormal
MsgBox "Your Data Has Successfully been Appended!", vbOKOnly + vbInformation, "SUCCESS!"
Else
iResponse = MsgBox("It appears that there are records in this table with that date, do you want to continue??", vbYesNo + vbCritical, "HOLD UP")
If iResponse = vbNo Then
Exit Sub
End If
End If
Error_Handler_Exit:
Exit Sub
Error_Handler:
Select Case Err.NUMBER
Case 94
Err.Clear
Resume Error_Handler_Exit
Case Else
MsgBox "Error No. " & Err.NUMBER & vbCrLf & "Description: " & Err.Description, vbExclamation, "Database Error"
Err.Clear
Resume Error_Handler_Exit
End Select
End Sub
Any suggestions/edit welcome, and thank you
Last edited: