I am getting a Run-time error 13: Type-mismatch with A Better Mouse Trap code - Help
Hi,
I am getting a Run-time error 13: Type-mismatch on the section of code below. The code that is in RED below is what the error is highlighting.
ghudson pointed me to his code (A Better Mouse Trap? sample) but I am getting the error and don’t know enough about VBA to get past this issue.
Can anyone help me?
Thanks,
James
Hi,
I am getting a Run-time error 13: Type-mismatch on the section of code below. The code that is in RED below is what the error is highlighting.
ghudson pointed me to his code (A Better Mouse Trap? sample) but I am getting the error and don’t know enough about VBA to get past this issue.
Can anyone help me?
Thanks,
James
Code:
[SIZE=3][FONT=Times New Roman]Private Sub bSave_Click()[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]On Error GoTo Err_bSave_Click[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] Me.tbHidden.SetFocus[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] If IsNull(Year) Or IsNull(Week_Number) Or IsNull(Payee_ID) Or IsNull(Payee_Name) Or IsNull(Billed_Amount) Or IsNull(Requested_Amount) Or IsNull(Calc_Pmt_Amount) Or IsNull(Assigned) Or IsNull(Email_Receipt_Date) Or IsNull(Form_Tracking_Number) Then[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] Beep[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] MsgBox "All required fields must be completed before you can save a record.", vbCritical, "Invalid Save"[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] Exit Sub[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] End If[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] Beep[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] Select Case MsgBox("Do you want to save your changes to the current record?" & vbCrLf & vbLf & " Yes: Saves Changes" & vbCrLf & " No: Does NOT Save Changes" & vbCrLf & " Cancel: Reset (Undo) Changes" & vbCrLf, vbYesNoCancel + vbQuestion, "Save Current Record?")[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] Case vbYes: 'Save the changes[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] Me.tbProperSave.Value = "Yes"[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] DoCmd.RunCommand acCmdSaveRecord[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] Case vbNo: 'Do not save or undo[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] 'Do nothing[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] Case vbCancel: 'Undo the changes[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] DoCmd.RunCommand acCmdUndo[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] Me.tbProperSave.Value = "No"[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] Case Else: 'Default case to trap any errors[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] 'Do nothing[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] End Select[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]Exit_bSave_Click:[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] Exit Sub[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]Err_bSave_Click:[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] If Err = 2046 Then 'The command or action Undo is not available now[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] Exit Sub[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] Else[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman][B][COLOR=red] MsgBox Err.Number, Err.Description[/COLOR][/B][/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] Resume Exit_bSave_Click[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] End If[/FONT][/SIZE]
[FONT=Times New Roman][SIZE=3]End Sub[/SIZE][/FONT]
Last edited: