[AccessD] Odd Error - Embarrassing Workaround

Rocky Smolin rockysmolin at bchacc.com
Tue Dec 5 08:03:02 CST 2017


Thanks.  I'll give that a roll.

r

-----Original Message-----
From: AccessD [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Jim
Dettman
Sent: Tuesday, December 05, 2017 4:44 AM
To: 'Access Developers discussion and problem solving'; 'Off Topic'
Subject: Re: [AccessD] Odd Error - Embarrassing Workaround

Rocky,

<<It blows up on Me.Bookmark = rsMe.Bookmark with an error 2001: You
canceled the previous operation.

So here's the odd thing: if I click Debug and see that line highlighted,
then click F5, the code carries on and displays the selected record.>>

 Sounds like you are are in the middle of another event or operation.
Hitting debug and then resuming allows the other event/operation to
complete.  

 Couple things:

1. I don't see a declare for lngID or rsMe.  I would explicitly declare both
if they are not declared elsewhere.

2. Change this:

    If IsNull(cboVendors) Then Exit Sub

 To

   If IsNull(Me.cboVendors) Then Exit Sub

3. Put Debug.Print "start" and Debug.Print "end" in each of the form events.
Then execute until you get the error.  Check the debug window when you do to
see what last executed.  Should give you a clue as to what is going on.

4. You could also try:

   dbEngine.Idle dbRefreshCache

 at the top of the routine.

 But I would try and figure this out....I don't think your workaround is
going to hold up.   Move to a faster / slower machine and could easily see a
different result.

Jim. 



-----Original Message-----
From: AccessD [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of
Rocky Smolin
Sent: Tuesday, November 28, 2017 11:24 AM
To: 'Access Developers discussion and problem solving'; 'Off Topic'
Subject: [AccessD] Odd Error - Embarrassing Workaround

Dear Lists:

 

In the code below which is in the after update event of a combo box, I want
to position the form to the selected vendor in the combo box list.  Cookie
cutter.  Done it a hundred times:

 

Private Sub cboVendors_AfterUpdate()

 
    If IsNull(cboVendors) Then Exit Sub
 
    lngID = Val(Me.cboVendors.Column(0))

    Set rsMe = Me.RecordsetClone

    rsMe.FindFirst "fldVendorID= " & lngID

    If rsMe.NoMatch = True Then

        MsgBox "Record Not Found", vbExclamation

    Else


        Me.Bookmark = rsMe.Bookmark

    End If

    Me.cmdExit.SetFocus
    Me.cboVendors.Visible = False

End sub

 

The code's a little more wordy than it needs to be because I've been trying
various fixes which, while they shouldn't work, often do in Access. J

 

It blows up on Me.Bookmark = rsMe.Bookmark with an error 2001: You canceled
the previous operation.

 

So here's the odd thing: if I click Debug and see that line highlighted,
then click F5, the code carries on and displays the selected record.

 

I've got a workaround that's so esthetically and professionally offensive
that I hesitate to show it here, but we're all friends, right?

 

Private Sub cboVendors_AfterUpdate()

 

    If IsNull(cboVendors) Then Exit Sub

    

    lngID = Val(Me.cboVendors.Column(0))

    Set rsMe = Me.RecordsetClone

    

    rsMe.FindFirst "fldVendorID= " & lngID

    If rsMe.NoMatch = True Then

        MsgBox "Record Not Found", vbExclamation

    Else

        On Error Resume Next

        Me.Bookmark = rsMe.Bookmark

        Me.Bookmark = rsMe.Bookmark

        On Error GoTo 0

    End If

    

    Me.cmdExit.SetFocus

   Me.cboVendors.Visible = False

 

End Sub

 

All I did was add the On Error line and issue the Bookmark a second time.
The second line apparently works. 

 

Can anyone help me avoid the embarrassment of having to explain to the next
programmer on this app why that code is there? Does anyone know what the
problem is and perhaps a fix?

 

I already tried recompile.  And also ran it through the decorrupter.

 

MTIA

 

 

Rocky Smolin (semi-ret.)

Beach Access Software

760-683-5777

 <http://www.bchacc.com> www.bchacc.com

 <http://www.e-z-mrp.com> www.e-z-mrp.com

Skype: rocky.smolin

 

 

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list