I'm brand new to VBA and I really appreciate any insight!
The following code was generated by converting from Macros to VBA using the design tab in Access 2016. Why did the action change after the conversion to VBA?
Prior to the conversion and minor edit below in bold, the If MacroError message box would appear if any required field was empty and the save button was pressed.
After the conversion and minor edit, the If macroError message is skipped and the Else "Your number is ... Record is saved" message box always displays. The Else "You number is ... Record is saved" now displays even when required fields are skipped.
----------------Beginning Code----------------------------
Private Sub Save_Record_and_Clear_Form_Click()
On Error GoTo Save_Record_and_Clear_Form_Click_Err
On Error Resume Next
DoCmd.GoToRecord , "", acNewRec
If (MacroError <> 0) Then
Beep
MsgBox MacroError.Description, vbOKOnly, ""
Else
MsgBox "Your record number is " & Me.ID & ". In the event of any changes request to this form, please provide this record number.", vbOKOnly, "Record is Saved – Thank you"
End If
Save_Record_and_Clear_Form_Click_Exit:
Exit Sub
Save_Record_and_Clear_Form_Click_Err:
MsgBox Error$
Resume Save_Record_and_Clear_Form_Click_Exit
End Sub
----------------- Ending Code --------------------------
Thank you for your help!
The following code was generated by converting from Macros to VBA using the design tab in Access 2016. Why did the action change after the conversion to VBA?
Prior to the conversion and minor edit below in bold, the If MacroError message box would appear if any required field was empty and the save button was pressed.
After the conversion and minor edit, the If macroError message is skipped and the Else "Your number is ... Record is saved" message box always displays. The Else "You number is ... Record is saved" now displays even when required fields are skipped.
----------------Beginning Code----------------------------
Private Sub Save_Record_and_Clear_Form_Click()
On Error GoTo Save_Record_and_Clear_Form_Click_Err
On Error Resume Next
DoCmd.GoToRecord , "", acNewRec
If (MacroError <> 0) Then
Beep
MsgBox MacroError.Description, vbOKOnly, ""
Else
MsgBox "Your record number is " & Me.ID & ". In the event of any changes request to this form, please provide this record number.", vbOKOnly, "Record is Saved – Thank you"
End If
Save_Record_and_Clear_Form_Click_Exit:
Exit Sub
Save_Record_and_Clear_Form_Click_Err:
MsgBox Error$
Resume Save_Record_and_Clear_Form_Click_Exit
End Sub
----------------- Ending Code --------------------------
Thank you for your help!