I have form for edit and delete
within me form edit or delete job
I have before_update trigger
Expand|Select|Wrap|Line Numbers
- Private Sub Form_beforeUpdate(Cancel As Integer)
- If IsNull(Me![JobTitle]) Then
- MsgBox "You must enter a Job first then you can save it", vbExclamation
- Cancel = True: Me![JobTitle].SetFocus
- ElseIf IsNull(Me![Job_ID]) Then
- MsgBox "You must enter The ID then you can save it", vbExclamation
- Cancel = True: Me![Job_ID].SetFocus
- End If
- End Sub
and clicked save it works great and the same for delete
but if select the value for combobox to research and the value of job_id is null in the viewed record i get error
number 3021 (no current record)
the code on search button
Expand|Select|Wrap|Line Numbers
- Private Sub Search_Click()
- Dim strjobRef As String
- Dim strSearch As String
- If IsNull(Me![cboJob_ID]) Or (Me![cboJob_ID]) = "" Then
- MsgBox "Please enter or Select a Job!", vbOKOnly, "Invalid Search Criterion!"
- Me![cboJob_ID].SetFocus
- Exit Sub
- End If
- DoCmd.ShowAllRecords
- DoCmd.GoToControl ("job_ID")
- DoCmd.FindRecord Me!cboJob_ID
- Job_ID.SetFocus
- strjobRef = Job_ID.Text
- cboJob_ID.SetFocus
- strSearch = cboJob_ID.Text
- If strjobRef = strSearch Then
- MsgBox "Match Found For: " & strSearch, , "Congratulations!"
- Job_ID.SetFocus
- cboJob_ID = ""
- Else
- MsgBox "Match Not Found For: " & strSearch & " - Please Try Again.", _
- , "Invalid Search Criterion!"
- cboJob_ID.SetFocus
- End If
- End Sub
Expand|Select|Wrap|Line Numbers
- docmd.showallrecords
thank you very much