After displaying search results, I want to be able to double click the identity number field and then the input form SubmissionDetai ls becomes the display form for the results of the data matching value of the selected identity number. With my code below I get a data type mismatch error. Please help me.......
Code:
Private Sub IdentityNumber_Click()
On Error GoTo IdentityNumber_Click_Err
On Error Resume Next
If (Form.Dirty) Then
DoCmd.RunCommand acCmdSaveRecord
End If
If (MacroError.Number <> 0) Then
Beep
MsgBox MacroError.Description, vbOKOnly, ""
Exit Sub
End If
On Error GoTo 0
DoCmd.OpenForm "SubmissionDetails", acNormal, , "[IdentityNumber]=" & IdentityNumber, , acDialog
'DoCmd.OpenForm "SubmissionDetails", acNormal, "", "[IdentityNumber]=" & IIf(Nz(IdentityNumber.Value) = vbNullString, "No value.", IdentityNumber.Value & "."), , acDialog
'IIf(Nz(IdentityNumber.Value) = vbNullString, "No value.", "Value is " & IdentityNumber.Value & ".")
If (Not IsNull(IdentityNumber)) Then
TempVars.Add "CurrentID", "[IdentityNumber]"
End If
If (IsNull(IdentityNumber)) Then
TempVars.Add "CurrentID", "Nz(DMax(""[IdentityNumber]"",[Form].[RecordSource]),0)"
End If
DoCmd.Requery ""
DoCmd.SearchForRecord , "", acFirst, "[IdentityNumber]=" & TempVars!CurrentID
TempVars.Remove "CurrentID"
IdentityNumber_Click_Exit:
Exit Sub
IdentityNumber_Click_Err:
MsgBox Error$
Resume IdentityNumber_Click_Exit
End Sub
Comment