P
Peter Stone
XP/Access 2003
I'm a novice.
Users select records by destination using a Combo box (cboDestination).
If there are no records for the selected destination, a message box asks if
they want to return to the record that was originally in the combo box. If
they click "No", I want the form to return to the original record. I presume
I need to bookmark the original record in the Before Update property and
return to it using the After Update property, but my attempts were
unsuccessful.
Private Sub cboDestination_AfterUpdate()
Dim resp, msg As String
Me.lstSelectRecord.Requery
Me.RecordsetClone.FindFirst _
"[DestinationsID] = " & Me![cboDestination]
If Not Me.RecordsetClone.NoMatch Then
'go to the first record in the set
Me.Bookmark = Me.RecordsetClone.Bookmark
Else
msg = "No records. Do you want to add records?"
resp = MsgBox(msg, vbQuestion + vbYesNo, "Add Record")
If resp = vbYes Then
'go to new record
DoCmd.GoToRecord , , acNewRec
Me.DestinationsID = Me.cboDestination
Else
'return to original record
CODE HERE TO RETURN TO THE ORIGINAL RECORD
End If
End If
Me.Refresh
End Sub
I'm a novice.
Users select records by destination using a Combo box (cboDestination).
If there are no records for the selected destination, a message box asks if
they want to return to the record that was originally in the combo box. If
they click "No", I want the form to return to the original record. I presume
I need to bookmark the original record in the Before Update property and
return to it using the After Update property, but my attempts were
unsuccessful.
Private Sub cboDestination_AfterUpdate()
Dim resp, msg As String
Me.lstSelectRecord.Requery
Me.RecordsetClone.FindFirst _
"[DestinationsID] = " & Me![cboDestination]
If Not Me.RecordsetClone.NoMatch Then
'go to the first record in the set
Me.Bookmark = Me.RecordsetClone.Bookmark
Else
msg = "No records. Do you want to add records?"
resp = MsgBox(msg, vbQuestion + vbYesNo, "Add Record")
If resp = vbYes Then
'go to new record
DoCmd.GoToRecord , , acNewRec
Me.DestinationsID = Me.cboDestination
Else
'return to original record
CODE HERE TO RETURN TO THE ORIGINAL RECORD
End If
End If
Me.Refresh
End Sub