J
johnlute
Dale Fye kindly gave me a hand with this:
Private Sub lstProfilesAssocs_DblClick(Cancel As Integer)
Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone
rs.FindFirst "txtProfileID='" & Me.lstProfilesAssocs.Column(0) &
"'"
If rs.NoMatch Then
MsgBox "Unable to find record!"
Else
Me.Bookmark = rs.Bookmark
End If
rs.Close
Set rs = Nothing
End Sub
It works great except I'd forgotten about a combo box [cbqrytypes]
which may be used to filter the form. If so, this results in a
filtered RecordSetClone which will be missing the matching record.
Yeesh.
I thought that maybe I could work it out. I've tried the following
however I know the problem is with having to requery the form. Of
course, this results in lost focus of what record was selected in the
listbox. Now the double-click has nowhere to take the user except to
the first record of the requeried recordset.
Am I on the right track? Is there something I can throw into the
OnLostFocus event that will permit the form to be requeried and still
navigate to the selected record in the listbox?
Thanks for your help!
Private Sub lstProfilesAssocs_DblClick(Cancel As Integer)
Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone
rs.FindFirst "txtProfileID='" & Me.lstProfilesAssocs.Column(0) &
"'"
If rs.NoMatch Then
If MsgBox("Sorry! Unable to navigate to this ID because the
form is currently filtered." & vbCrLf & _
"Click OK to remove the filter and navigate to this ID.",
vbOKOnly + _
vbQuestion) = vbOK Then
[cbqrytypes] = Null
Me.cbqrytypes.Requery
Me.cbProfileID.Requery
Forms![KEYSTONEqryrpt].Form.Requery
Me.cbProfileID.SetFocus
Cancel = True
End If
Else
Me.Bookmark = rs.Bookmark
End If
rs.Close
Set rs = Nothing
End Sub
Private Sub lstProfilesAssocs_DblClick(Cancel As Integer)
Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone
rs.FindFirst "txtProfileID='" & Me.lstProfilesAssocs.Column(0) &
"'"
If rs.NoMatch Then
MsgBox "Unable to find record!"
Else
Me.Bookmark = rs.Bookmark
End If
rs.Close
Set rs = Nothing
End Sub
It works great except I'd forgotten about a combo box [cbqrytypes]
which may be used to filter the form. If so, this results in a
filtered RecordSetClone which will be missing the matching record.
Yeesh.
I thought that maybe I could work it out. I've tried the following
however I know the problem is with having to requery the form. Of
course, this results in lost focus of what record was selected in the
listbox. Now the double-click has nowhere to take the user except to
the first record of the requeried recordset.
Am I on the right track? Is there something I can throw into the
OnLostFocus event that will permit the form to be requeried and still
navigate to the selected record in the listbox?
Thanks for your help!
Private Sub lstProfilesAssocs_DblClick(Cancel As Integer)
Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone
rs.FindFirst "txtProfileID='" & Me.lstProfilesAssocs.Column(0) &
"'"
If rs.NoMatch Then
If MsgBox("Sorry! Unable to navigate to this ID because the
form is currently filtered." & vbCrLf & _
"Click OK to remove the filter and navigate to this ID.",
vbOKOnly + _
vbQuestion) = vbOK Then
[cbqrytypes] = Null
Me.cbqrytypes.Requery
Me.cbProfileID.Requery
Forms![KEYSTONEqryrpt].Form.Requery
Me.cbProfileID.SetFocus
Cancel = True
End If
Else
Me.Bookmark = rs.Bookmark
End If
rs.Close
Set rs = Nothing
End Sub