If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
bookmark bug access 2003
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 |
#2
|
|||
|
|||
bookmark bug access 2003
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@uwe wrote in message news:9eca299f308b9@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 |
#3
|
|||
|
|||
bookmark bug access 2003
"Allen Browne" wrote in
: 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.) Also note that the find combo wizard since A2000 writes really bad code, much worse than the A97 and earlier wizards. I don't know why MS decided to use the Recordset instead of the RecordsetClone for this. It makes no sense to me at all. -- David W. Fenton http://www.dfenton.com/ usenet at dfenton dot com http://www.dfenton.com/DFA/ |
#4
|
|||
|
|||
bookmark bug access 2003
"Allen Browne" wrote in
: 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 Also, I think it makes much more sense to just use a WITH block, so you don't have to have a recordset variable: Private Sub cbosearch_AfterUpdate() ' Find the record that matches the control. On Error GoTo ProcError With Me.RecordsetClone .FindFirst "[Lname] = '" & Me![cbosearch] & "'" If .NoMatch Then MsgBox "Not found" Else If Me.Dirty Then Me.Dirty = False End If Me.Bookmark = .Bookmark End If End With ExitProc: Exit Sub ProcError: MsgBox "Error: " & Err.Number & ". " & Err.Description Resume ExitProc End Sub I've never quite understood assigning a recordset variable for an object that already exists. Also, I question the use of single quotes. If the name is "O'Connor" you're in trouble. -- David W. Fenton http://www.dfenton.com/ usenet at dfenton dot com http://www.dfenton.com/DFA/ |
Thread Tools | |
Display Modes | |
|
|