Type mismatch (have searched)

A

albycindy

When I try to close my form, using the code below (simple), the form will not
close and I get a Type mismatch error. The error box says nothing else, just
Type mismatch. I have checked my References and compiled my database and
there are no problems there. Does anyone have any suggestions? (Using Access
2002)

Private Sub cmdClose_Click()
On Error GoTo Err_cmdClose_Click

DoCmd.Close "frmContact"

Exit_cmdClose_Click:
Exit Sub

Err_cmdClose_Click:
MsgBox Err.Description
Resume Exit_cmdClose_Click

End Sub

Private Sub Form_Close()
If Not IsNull(Me.OpenArgs) Then
DoCmd.OpenForm Me.OpenArgs, , , "[pkCRDNumber]=" & Me.pkCRDNumber,
acFormEdit
End If
End Sub
 
W

Wayne Morgan

By the time you get to the Close event, the value of Me.pkCRDNumber may no
longer be available. Try moving the code to the Unload event and see if that
works. Also, try a Debug.Print before the DoCmd statement to verify that the
value is what is desired.

Example:
Debug.Print Me.pkCRDNumber
 
J

John Spencer

I believe the correct format for this is as follows.

DoCmd.Close acForm, "frmContact"

If you are going to specify the name of the object to be closed, you have to
specify the type of the object.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top