C
cmco
I use a combo box "cmboJobNamep3" to find records on my form "frmJobs". I
want to be able to add a new record and delete a record on the same form and
have placed "cmdNewJobp3" and "cmdDeleteJobp3" command buttons on the form.
These buttons do as I intend except that I would like the combo box list to
update. After adding a new record the record does not show up in the list
even though the record count on the Navigation buttons at the bottom of the
form inceases and I can to to the new record. When a record is deleted, it
still shows up in the combe list as "#Deleted" and the Navagation record
count reduces by one. If I select the combo "#deleted" record I get an Access
Error. If I close the form and reopen the form, everything is in order. What
else do I need to do? The code behind these controsl is as follows:
Private Sub cmdNewJobp3_Click()
Dim db As Database
Dim rs As Recordset
On Error GoTo Err_cmdNewJobp3_Click
DoCmd.GoToRecord , , acNewRec
Set db = CurrentDb()
Set rs = db.OpenRecordset("tblJobs")
rs.Edit
rs.Update
rs.Close
Exit_cmdNewJobp3_Click:
Exit Sub
Err_cmdNewJobp3_Click:
MsgBox Err.Description
Resume Exit_cmdNewJobp3_Click
End Sub
Private Sub cmdDeleteJobp3_Click()
On Error GoTo Err_cmdDeleteJobp3_Click
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
Exit_cmdDeleteJobp3_Click:
Exit Sub
Err_cmdDeleteJobp3_Click:
MsgBox Err.Description
Resume Exit_cmdDeleteJobp3_Click
End Sub
Private Sub cboJobName1_AfterUpdate()
Dim rs As Recordset, Criteria
Set rs = Me.RecordsetClone
Criteria = "[JobID] = " & Me.cboJobName1
rs.FindFirst Criteria
If Not rs.NoMatch = True Then
Me.Bookmark = rs.Bookmark
End If
End Sub
want to be able to add a new record and delete a record on the same form and
have placed "cmdNewJobp3" and "cmdDeleteJobp3" command buttons on the form.
These buttons do as I intend except that I would like the combo box list to
update. After adding a new record the record does not show up in the list
even though the record count on the Navigation buttons at the bottom of the
form inceases and I can to to the new record. When a record is deleted, it
still shows up in the combe list as "#Deleted" and the Navagation record
count reduces by one. If I select the combo "#deleted" record I get an Access
Error. If I close the form and reopen the form, everything is in order. What
else do I need to do? The code behind these controsl is as follows:
Private Sub cmdNewJobp3_Click()
Dim db As Database
Dim rs As Recordset
On Error GoTo Err_cmdNewJobp3_Click
DoCmd.GoToRecord , , acNewRec
Set db = CurrentDb()
Set rs = db.OpenRecordset("tblJobs")
rs.Edit
rs.Update
rs.Close
Exit_cmdNewJobp3_Click:
Exit Sub
Err_cmdNewJobp3_Click:
MsgBox Err.Description
Resume Exit_cmdNewJobp3_Click
End Sub
Private Sub cmdDeleteJobp3_Click()
On Error GoTo Err_cmdDeleteJobp3_Click
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
Exit_cmdDeleteJobp3_Click:
Exit Sub
Err_cmdDeleteJobp3_Click:
MsgBox Err.Description
Resume Exit_cmdDeleteJobp3_Click
End Sub
Private Sub cboJobName1_AfterUpdate()
Dim rs As Recordset, Criteria
Set rs = Me.RecordsetClone
Criteria = "[JobID] = " & Me.cboJobName1
rs.FindFirst Criteria
If Not rs.NoMatch = True Then
Me.Bookmark = rs.Bookmark
End If
End Sub