Urgent Please help! If Not IsNull(Dlookup...
My goal is to findout if the record exist, open a form message, else, add the record.
Please check my code. it always go on error when it reaches line 9. So from line 9 to line 19, does not work. Please urgent!!!
Error message is "The expression you entered as a query parameter produced this error: 'The object does not have the automation object' WS002."
1 Private Sub cmdReserveWS_Click()
2 On Error GoTo Err_cmdReserveWS_Click
3
4 Dim MainfrmWS As String 'declare variable
5
6 MainfrmWS = Forms![TestMyDMax1]![txtIAssignWS] 'set
7 variable value to your textbox
8
9 If Not IsNull(DLookup("[Rectype]", "testWSLog", "[Rectype]10 = " & MainfrmWS)) Then
11 DoCmd.OpenForm "cfMsgJVExist", acNormal, "", ,
12 acNormal
13 DoCmd.Close acForm, "TestMYDmax1"
14 Else
15 Rectype = MainfrmWS
16 DoCmd.DoMenuItem acFormBar, acRecordsMenu,
17 acSaveRecord, , acMenuVer70
18 DoCmd.Close acForm, "TestMYDmax1"
19 End If
20 Exit_cmdReserveWS_Click:
21 Exit Sub
Err_cmdReserveWS_Click:
MsgBox Err.Description
Resume Exit_cmdReserveWS_Click
End Sub
Thanks.
My goal is to findout if the record exist, open a form message, else, add the record.
Please check my code. it always go on error when it reaches line 9. So from line 9 to line 19, does not work. Please urgent!!!
Error message is "The expression you entered as a query parameter produced this error: 'The object does not have the automation object' WS002."
1 Private Sub cmdReserveWS_Click()
2 On Error GoTo Err_cmdReserveWS_Click
3
4 Dim MainfrmWS As String 'declare variable
5
6 MainfrmWS = Forms![TestMyDMax1]![txtIAssignWS] 'set
7 variable value to your textbox
8
9 If Not IsNull(DLookup("[Rectype]", "testWSLog", "[Rectype]10 = " & MainfrmWS)) Then
11 DoCmd.OpenForm "cfMsgJVExist", acNormal, "", ,
12 acNormal
13 DoCmd.Close acForm, "TestMYDmax1"
14 Else
15 Rectype = MainfrmWS
16 DoCmd.DoMenuItem acFormBar, acRecordsMenu,
17 acSaveRecord, , acMenuVer70
18 DoCmd.Close acForm, "TestMYDmax1"
19 End If
20 Exit_cmdReserveWS_Click:
21 Exit Sub
Err_cmdReserveWS_Click:
MsgBox Err.Description
Resume Exit_cmdReserveWS_Click
End Sub
Thanks.