Prev: Resume
Next: Chart Question
From: David on
I have a combo box that when selected pulls up records in another
table. It's worked flawlessly in Access 2003-2007. But in Access
2010 I get the 3159 error, and a notice that a bookmark is invalid.

Here's the code in the debugger

Private Sub Combo20_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[Lname] = '" & Me![Combo20] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

This is the code the debuugger highlights:
Me.Bookmark = rs.Bookmark

Any thoughts?

Thanks in advance

From: Dirk Goldgar on
"David" <berger.david(a)gmail.com> wrote in message
news:c2540451-4665-428b-97af-677ccfad0af2(a)r36g2000yqm.googlegroups.com...
>I have a combo box that when selected pulls up records in another
> table. It's worked flawlessly in Access 2003-2007. But in Access
> 2010 I get the 3159 error, and a notice that a bookmark is invalid.
>
> Here's the code in the debugger
>
> Private Sub Combo20_AfterUpdate()
> ' Find the record that matches the control.
> Dim rs As Object
>
> Set rs = Me.Recordset.Clone
> rs.FindFirst "[Lname] = '" & Me![Combo20] & "'"
> If Not rs.EOF Then Me.Bookmark = rs.Bookmark
> End Sub
>
> This is the code the debuugger highlights:
> Me.Bookmark = rs.Bookmark
>
> Any thoughts?


Change this line of code:

> If Not rs.EOF Then Me.Bookmark = rs.Bookmark

to this:

If Not rs.NoMatch Then Me.Bookmark = rs.Bookmark

.... and see if you get the same error. Maybe you will, maybe you won't, but
that will eliminate one possibility.

Although the code you posted may have been written by Access combo box
wizard, it's still wrong, and always has been. If the record isn't found,
the recordset's .NoMatch property is set, not its .EOF property. So as the
code was, if the record was not found, the code would try to use the
recordset's Bookmark property anyway. Maybe that's what's going on.

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

From: David on
Dirk: I made this change, but the error is unchanged.

The combo box wizard did write the original code.
Anything else?

db



On Apr 8, 9:42 pm, "Dirk Goldgar"
<d...(a)NOdataSPAMgnostics.com.invalid> wrote:
> "David" <berger.da...(a)gmail.com> wrote in message
>
> news:c2540451-4665-428b-97af-677ccfad0af2(a)r36g2000yqm.googlegroups.com...
>
>
>
> >I have a combo box that when selected pulls up records in another
> > table.  It's worked flawlessly in Access 2003-2007.  But in Access
> > 2010  I get the 3159 error, and a notice that a bookmark is invalid.
>
> > Here's the code in the debugger
>
> > Private Sub Combo20_AfterUpdate()
> >    ' Find the record that matches the control.
> >    Dim rs As Object
>
> >    Set rs = Me.Recordset.Clone
> >    rs.FindFirst "[Lname] = '" & Me![Combo20] & "'"
> >    If Not rs.EOF Then Me.Bookmark = rs.Bookmark
> > End Sub
>
> > This is the code the debuugger highlights:
> > Me.Bookmark = rs.Bookmark
>
> > Any thoughts?
>
> Change this line of code:
>
> >    If Not rs.EOF Then Me.Bookmark = rs.Bookmark
>
> to this:
>
>     If Not rs.NoMatch Then Me.Bookmark = rs.Bookmark
>
> ... and see if you get the same error.  Maybe you will, maybe you won't, but
> that will eliminate one possibility.
>
> Although the code you posted may have been written by Access combo box
> wizard, it's still wrong, and always has been.  If the record isn't found,
> the recordset's .NoMatch property is set, not its .EOF property.  So as the
> code was, if the record was not found, the code would try to use the
> recordset's Bookmark property anyway.  Maybe that's what's going on.
>
> --
> Dirk Goldgar, MS Access MVP
> Access tips:www.datagnostics.com/tips.html
>
> (please reply to the newsgroup)

From: Dirk Goldgar on
"David" wrote in message
news:16d4190c-8b60-4b0d-83f5-606830bdfa8d(a)u31g2000yqb.googlegroups.com...
> Dirk: I made this change, but the error is unchanged.

Drat.

> The combo box wizard did write the original code.
> Anything else?

Well, you can simplify the code a whole lot more, and see if that makes the
error go away. This all by itself ought to work:

'------ start of suggested code ------
Private Sub Combo20_AfterUpdate()

Me.Recordset.FindFirst "[Lname] = '" & Me![Combo20] & "'"

End Sub
'------ end of suggested code ------

That is, provided that the string you're looking for doesn't contain the
single-quote/apostrophe character ('). That code would raise an error if
you tried to find the name O'Malley. You aren't looking for such a name
when it fails, are you?

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

From: David on
On Apr 8, 10:35 pm, "Dirk Goldgar"
<d...(a)NOdataSPAMgnostics.com.invalid> wrote:
> "David" wrote in message
>
> news:16d4190c-8b60-4b0d-83f5-606830bdfa8d(a)u31g2000yqb.googlegroups.com...
>
> > Dirk:  I made this change, but the error is unchanged.
>
> Drat.
>
> > The combo box wizard did write the original code.
> > Anything else?
>
> Well, you can simplify the code a whole lot more, and see if that makes the
> error go away.  This all by itself ought to work:
>
> '------ start of suggested code ------
> Private Sub Combo20_AfterUpdate()
>
>     Me.Recordset.FindFirst "[Lname] = '" & Me![Combo20] & "'"
>
> End Sub
> '------ end of suggested code ------
>
> That is, provided that the string you're looking for doesn't contain the
> single-quote/apostrophe character (').  That code would raise an error if
> you tried to find the name O'Malley.  You aren't looking for such a name
> when it fails, are you?
>
> --
> Dirk Goldgar, MS Access MVP
> Access tips:www.datagnostics.com/tips.html
>
> (please reply to the newsgroup)

That takes away the error, but also removed all the functionality.
The dropdown previously populated a subform, but now it doesn't. I
can only assume thje bookmark functionality was being referred to to
do that.

Any other ideas?
 |  Next  |  Last
Pages: 1 2
Prev: Resume
Next: Chart Question