Listbox bookmark error

  • Thread starter Thread starter Nick Mirro
  • Start date Start date
N

Nick Mirro

I have a listbox that shows records from a query. These records are
separate from the form's
recordsource. The listbox also is used as a record selector for the form.
If the
form is filtered prior to selecting a record from the listbox,
ShowAllRecords clears it,
but causes this error: (only happens if form is filtered)

*** "Not a valid bookmark"


Private Sub lstRecentPatients_AfterUpdate()

' Find the record that matches the control.
Dim rs As Object

' MsgBox Me.ContactsList
Set rs = Me.Recordset.Clone

DoCmd.ShowAllRecords
rs.FindFirst "[PatientID] = " & Nz(Me![lstRecentPatients], 0)
If Not rs.EOF Then Me.Bookmark = rs.Bookmark***

End Sub


I'm not sure what it means? Any way to prevent this error?
 
Looks like you have an extra . between Recordset and Clone. This should be
one word RecordsetClone. If that is the case, rs will not have a bookmark
since it is not a valid recordset.

Kelvin
 
Thanks for the reply. Without the "." I now get "object invalid or no
longer set."

Nick


Private Sub lstRecentPatients_AfterUpdate()

' Find the record that matches the control.
Dim rs As Object

' MsgBox Me.ContactsList
Set rs = Me.RecordsetClone
DoCmd.ShowAllRecords
rs.FindFirst "[PatientID] = " & Nz(Me![lstRecentPatients], 0)
If Not rs.EOF Then Me.Bookmark = rs.Bookmark

End Sub



Kelvin Lu said:
Looks like you have an extra . between Recordset and Clone. This should be
one word RecordsetClone. If that is the case, rs will not have a bookmark
since it is not a valid recordset.

Kelvin

Nick Mirro said:
I have a listbox that shows records from a query. These records are
separate from the form's
recordsource. The listbox also is used as a record selector for the form.
If the
form is filtered prior to selecting a record from the listbox,
ShowAllRecords clears it,
but causes this error: (only happens if form is filtered)

*** "Not a valid bookmark"


Private Sub lstRecentPatients_AfterUpdate()

' Find the record that matches the control.
Dim rs As Object

' MsgBox Me.ContactsList
Set rs = Me.Recordset.Clone

DoCmd.ShowAllRecords
rs.FindFirst "[PatientID] = " & Nz(Me![lstRecentPatients], 0)
If Not rs.EOF Then Me.Bookmark = rs.Bookmark***

End Sub


I'm not sure what it means? Any way to prevent this error?
 
Try Recordsetclone. I don't know if there is a ".Clone" property of the
"Recordset" object of recent versions of Access, but there definitely is a
Recordsetclone property, at least from Access 2.0 to current.

Larry Linson
Microsoft Access MVP


Nick Mirro said:
Thanks for the reply. Without the "." I now get "object invalid or no
longer set."

Nick


Private Sub lstRecentPatients_AfterUpdate()

' Find the record that matches the control.
Dim rs As Object

' MsgBox Me.ContactsList
Set rs = Me.RecordsetClone
DoCmd.ShowAllRecords
rs.FindFirst "[PatientID] = " & Nz(Me![lstRecentPatients], 0)
If Not rs.EOF Then Me.Bookmark = rs.Bookmark

End Sub



Kelvin Lu said:
Looks like you have an extra . between Recordset and Clone. This should be
one word RecordsetClone. If that is the case, rs will not have a bookmark
since it is not a valid recordset.

Kelvin

Nick Mirro said:
I have a listbox that shows records from a query. These records are
separate from the form's
recordsource. The listbox also is used as a record selector for the form.
If the
form is filtered prior to selecting a record from the listbox,
ShowAllRecords clears it,
but causes this error: (only happens if form is filtered)

*** "Not a valid bookmark"


Private Sub lstRecentPatients_AfterUpdate()

' Find the record that matches the control.
Dim rs As Object

' MsgBox Me.ContactsList
Set rs = Me.Recordset.Clone

DoCmd.ShowAllRecords
rs.FindFirst "[PatientID] = " & Nz(Me![lstRecentPatients], 0)
If Not rs.EOF Then Me.Bookmark = rs.Bookmark***

End Sub


I'm not sure what it means? Any way to prevent this error?
 
I did, and got the previously mentioned error.

Nick


Larry Linson said:
Try Recordsetclone. I don't know if there is a ".Clone" property of the
"Recordset" object of recent versions of Access, but there definitely is a
Recordsetclone property, at least from Access 2.0 to current.

Larry Linson
Microsoft Access MVP


Nick Mirro said:
Thanks for the reply. Without the "." I now get "object invalid or no
longer set."

Nick


Private Sub lstRecentPatients_AfterUpdate()

' Find the record that matches the control.
Dim rs As Object

' MsgBox Me.ContactsList
Set rs = Me.RecordsetClone
DoCmd.ShowAllRecords
rs.FindFirst "[PatientID] = " & Nz(Me![lstRecentPatients], 0)
If Not rs.EOF Then Me.Bookmark = rs.Bookmark

End Sub



Kelvin Lu said:
Looks like you have an extra . between Recordset and Clone. This
should
be
one word RecordsetClone. If that is the case, rs will not have a bookmark
since it is not a valid recordset.

Kelvin

I have a listbox that shows records from a query. These records are
separate from the form's
recordsource. The listbox also is used as a record selector for the form.
If the
form is filtered prior to selecting a record from the listbox,
ShowAllRecords clears it,
but causes this error: (only happens if form is filtered)

*** "Not a valid bookmark"


Private Sub lstRecentPatients_AfterUpdate()

' Find the record that matches the control.
Dim rs As Object

' MsgBox Me.ContactsList
Set rs = Me.Recordset.Clone

DoCmd.ShowAllRecords
rs.FindFirst "[PatientID] = " & Nz(Me![lstRecentPatients], 0)
If Not rs.EOF Then Me.Bookmark = rs.Bookmark***

End Sub


I'm not sure what it means? Any way to prevent this error?
 
Try

Dim rs As Object
Set rs = Me.RecordsetClone
rs.FindFirst "[PatientID] = " & Nz(Me![lstRecentPatients], 0)
If rs.nomatch Then
MsgBox "No records found."
else
Me.Bookmark = rs.Bookmark
end if

I think it might be the .EOF that's causing the problem.

Kelvin

Nick Mirro said:
I did, and got the previously mentioned error.

Nick


Larry Linson said:
Try Recordsetclone. I don't know if there is a ".Clone" property of the
"Recordset" object of recent versions of Access, but there definitely is a
Recordsetclone property, at least from Access 2.0 to current.

Larry Linson
Microsoft Access MVP


Nick Mirro said:
Thanks for the reply. Without the "." I now get "object invalid or no
longer set."

Nick


Private Sub lstRecentPatients_AfterUpdate()

' Find the record that matches the control.
Dim rs As Object

' MsgBox Me.ContactsList
Set rs = Me.RecordsetClone
DoCmd.ShowAllRecords
rs.FindFirst "[PatientID] = " & Nz(Me![lstRecentPatients], 0)
If Not rs.EOF Then Me.Bookmark = rs.Bookmark

End Sub



Looks like you have an extra . between Recordset and Clone. This should
be
one word RecordsetClone. If that is the case, rs will not have a bookmark
since it is not a valid recordset.

Kelvin

I have a listbox that shows records from a query. These records are
separate from the form's
recordsource. The listbox also is used as a record selector for the
form.
If the
form is filtered prior to selecting a record from the listbox,
ShowAllRecords clears it,
but causes this error: (only happens if form is filtered)

*** "Not a valid bookmark"


Private Sub lstRecentPatients_AfterUpdate()

' Find the record that matches the control.
Dim rs As Object

' MsgBox Me.ContactsList
Set rs = Me.Recordset.Clone

DoCmd.ShowAllRecords
rs.FindFirst "[PatientID] = " & Nz(Me![lstRecentPatients], 0)
If Not rs.EOF Then Me.Bookmark = rs.Bookmark***

End Sub


I'm not sure what it means? Any way to prevent this error?
 
Back
Top