Type mismatch (have searched)

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
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.
 
Back
Top