From: timbits35 via AccessMonster.com on
Hi,

I am using Access 2003 11.8166.8221 SP3. Can anyone confirm or deny if the
bookmark bug has been fixed in this version? I am using the bookmark in a
form to locate records and even though I have not encountered any problems, I
wonder if I am safe. Here is my code. As well is it better to use On Click or
After Update.

Private Sub cbosearch_AfterUpdate()
' Find the record that matches the control.
On Error GoTo ProcError
Dim rs As Object

Set rs = Me.RecordsetClone
rs.FindFirst "[Lname] = '" & Me![cbosearch] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
ExitProc:
Exit Sub
ProcError:
MsgBox "Error: " & Err.Number & ". " & Err.Description
Resume ExitProc
End Sub

Thank you,
Liane

--
Message posted via http://www.accessmonster.com

From: Allen Browne on
Hasn't been seen for years; should be fine in this version.

Suggestions:
1. Explicitly save any edits in progress. This triggers any pending events,
and will avoid some weird (difficult to understand/debug) errors.

2. Test NoMatch rather than EOF after the FindFirst.

3. It may be better to be explicit about the kind of recordset you are
searching. In general, it's better to be as explicit as possible.

4. Consider letting the user know if there was no match.

5. Presumably cbosearch is unbound (so it's not trying to save a value.)

6. You might want to consider filtering rather than finding the first match
(since there could be multiple matches.)

Ignoring #6:

Private Sub cbosearch_AfterUpdate()
' Find the record that matches the control.
On Error GoTo ProcError
Dim rs As DAO.Recordset

If Me.Dirty Then Me.Dirty = False
Set rs = Me.RecordsetClone
rs.FindFirst "[Lname] = '" & Me![cbosearch] & "'"
If rs.NoMatch Then
MsgBox "Not found"
Else
Me.Bookmark = rs.Bookmark
End If
ExitProc:
Set rs = Nothing
Exit Sub

ProcError:
MsgBox "Error: " & Err.Number & ". " & Err.Description
Resume ExitProc
End Sub



--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.


"timbits35 via AccessMonster.com" <u34694(a)uwe> wrote in message
news:9eca299f308b9(a)uwe...
> Hi,
>
> I am using Access 2003 11.8166.8221 SP3. Can anyone confirm or deny if the
> bookmark bug has been fixed in this version? I am using the bookmark in a
> form to locate records and even though I have not encountered any
> problems, I
> wonder if I am safe. Here is my code. As well is it better to use On Click
> or
> After Update.
>
> Private Sub cbosearch_AfterUpdate()
> ' Find the record that matches the control.
> On Error GoTo ProcError
> Dim rs As Object
>
> Set rs = Me.RecordsetClone
> rs.FindFirst "[Lname] = '" & Me![cbosearch] & "'"
> If Not rs.EOF Then Me.Bookmark = rs.Bookmark
> ExitProc:
> Exit Sub
> ProcError:
> MsgBox "Error: " & Err.Number & ". " & Err.Description
> Resume ExitProc
> End Sub
>
> Thank you,
> Liane
>
> --
> Message posted via http://www.accessmonster.com
>