Listbox bookmark error

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?
 
K

Kelvin Lu

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
 
N

Nick Mirro

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?
 
L

Larry Linson

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?
 
N

Nick Mirro

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?
 
K

Kelvin Lu

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

bookmark Problem 2
lost focus...? 3
Bookmark Listbox 4
RunTime Error 3070 8
Troublesome listbox 1
Filter unbound search combo box based on filter in form's OnOpenEvent 3
Error 2237 8
Requery/bookmark 4

Top