Run-time error '13': Type mismatch

RDSJMS

Registered User.
Local time
Today, 12:40
Joined
Jan 25, 2006
Messages
30
I don't understand why I'm getting this message.

I have a form that is based on a parameter query. The user inputs an item number and the form opens in edit mode. The user clicks the "duplicate" command button and then changes the item number. I've incorporated GHudson's "A Better Mouse Trap" logic and when clicking "save" I get the type mismatch error.

I don't understand why Access is not returning the 3022 duplicate entry error.

When I click "debug" Access highlights the line as shown below:

Code:
Err_bSave_Click:
    If Err = 2046 Then 'The command or action Undo is not available now
        Exit Sub
    Else
        [COLOR="Blue"]MsgBox Err.Number, Err.Description[/COLOR]
        Resume Exit_bSave_Click
    End If
    
End Sub

Any and all assistance is appreciated.

Randy
 
Disable error handling and try it.
I think the MSGBOX is giving the error you are getting, not what the real issue is.
I usually use MsgBox str(Err.Number) & " - " & Err.Description
 
FoFa,

That got rid of the type mismatch error. However, while the "save" button appears to be functioning as designed by GHudson, the record is not being saved...when clicking the "close" button, GHudson's code is warning me to save the record. It's a vicious cycle.

Any other ideas?

Randy
 
Is the record not being saved, or is the message it needs to be saved in error?
 
The record is not being saved because it would create a duplicate. There is no longer any message displayed.
 
Anyone else have any ideas?

Any and all assistance is appreciated.

Randy
 
First, change your msgbox to be like this: MsgBox str(Err.Number) & " - " & Err.Description
Try that initially (we can add to it later). Your original message was because your MSGBOX was formatted improperly.

How ever if you trying to check for duplicates, I think most people find it better to do that in code rather than let Access detect it. Do a search for duplicate checking in the forums and you will get code examples.
 

Users who are viewing this thread

Back
Top Bottom