kiss.shoremishra
Registered User.
- Local time
- Today, 17:18
- Joined
- Feb 4, 2017
- Messages
- 19
I actually created a user form with 5 input controls first 2 Combo box then 2 text box and last combo box. The first 2 and last combo box are mandatory fields where user had to mandatory select the value only then query will be executed and record gets added. Code works properly for first time but in second time (As a test, I tried again to miss the mandatory field & click) but instead of message it gives "Runtime Error 3134" Here below is my code.
Private Sub Update_Button_Click()
If IsNull(Me.[cbo_WRINPrefix]) Or Me.[cbo_WRINPrefix] = "" Then
MsgBox "WRIN Prefix is mandatory", vbOKOnly, "Input Error"
Me.[cbo_WRINPrefix].SetFocus
ElseIf IsNull(Me.[cbo_GlobalAI]) Or Me.[cbo_GlobalAI] = "" Then
MsgBox "Global AI is mandatory", vbOKOnly, "Input Error"
Me.[cbo_GlobalAI].SetFocus
ElseIf IsNull(Me.[cbo_Updated_By]) Or Me.[cbo_Updated_By] = "" Then
MsgBox "It is important to update your name, Please select your name from the Drop down", vbOKOnly, "Input Error"
Me.[cbo_Updated_By].SetFocus
Else
Me.[McD_Comments_textbox].SetFocus
End If
'End If
'Exit Sub
'End If
'Add data to Table tbl_GLOBAL_AI_WRIN_PREFIX_MAP_MASTER
CurrentDb.Execute "INSERT INTO tbl_GLOBAL_AI_WRIN_PREFIX_MAP_MASTER ([WRIN PREFIX], [CORE_AI_ID], [HAVI Comments], [McD Comments], [Insert_Date], [Update_Date], [Updated_By]) " & _
" VALUES(" & Me.[cbo_WRINPrefix] & ",'" & Me.[cbo_GlobalAI] & "','" & Me.[Text_HAVI_Comments] & "','" & Me.[McD_Comments_textbox] & "','" & Date & "','" & Date & "','" & Me.[cbo_Updated_By] & "')"
MsgBox "Record added."
Me.[cbo_WRINPrefix] = ""
Me.[cbo_GlobalAI] = ""
Me.[Text_HAVI_Comments] = ""
Me.[McD_Comments_textbox] = ""
Me.[cbo_Updated_By] = ""
Me.cbo_Updated_By.Requery
Me.Refresh
Exit Sub
End Sub
Private Sub Update_Button_Click()
If IsNull(Me.[cbo_WRINPrefix]) Or Me.[cbo_WRINPrefix] = "" Then
MsgBox "WRIN Prefix is mandatory", vbOKOnly, "Input Error"
Me.[cbo_WRINPrefix].SetFocus
ElseIf IsNull(Me.[cbo_GlobalAI]) Or Me.[cbo_GlobalAI] = "" Then
MsgBox "Global AI is mandatory", vbOKOnly, "Input Error"
Me.[cbo_GlobalAI].SetFocus
ElseIf IsNull(Me.[cbo_Updated_By]) Or Me.[cbo_Updated_By] = "" Then
MsgBox "It is important to update your name, Please select your name from the Drop down", vbOKOnly, "Input Error"
Me.[cbo_Updated_By].SetFocus
Else
Me.[McD_Comments_textbox].SetFocus
End If
'End If
'Exit Sub
'End If
'Add data to Table tbl_GLOBAL_AI_WRIN_PREFIX_MAP_MASTER
CurrentDb.Execute "INSERT INTO tbl_GLOBAL_AI_WRIN_PREFIX_MAP_MASTER ([WRIN PREFIX], [CORE_AI_ID], [HAVI Comments], [McD Comments], [Insert_Date], [Update_Date], [Updated_By]) " & _
" VALUES(" & Me.[cbo_WRINPrefix] & ",'" & Me.[cbo_GlobalAI] & "','" & Me.[Text_HAVI_Comments] & "','" & Me.[McD_Comments_textbox] & "','" & Date & "','" & Date & "','" & Me.[cbo_Updated_By] & "')"
MsgBox "Record added."
Me.[cbo_WRINPrefix] = ""
Me.[cbo_GlobalAI] = ""
Me.[Text_HAVI_Comments] = ""
Me.[McD_Comments_textbox] = ""
Me.[cbo_Updated_By] = ""
Me.cbo_Updated_By.Requery
Me.Refresh
Exit Sub
End Sub