Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2002
    Thanked 0 Times in 0 Posts

    VB code flows randomly (2000)

    I'm trying to modify some VB code that's in the 'On Lost Focus' event for a field. The code that I am providing here has been reduced in complexity for illustration, but still reproduces the problem. For instance, I have explicitly assigned values to the PNIEndValue and PNIStartValue variables, rather than involving outside code to do so.

    When this code is invoked, it starts off by bouncing back and forth between PNIEndValue = "ICA" and PNIStartValue = "PNI-Official Check" -- although I can see it flash very very briefly on If PNIEndValue <> PNIStartValue while it's doing this. After doing this about 30 times, it finally does travel down line by line, all the way to End Sub, but then loops part of the way way up and repeats this for a couple of dozen times.

    The funny thing is that all of this is transparent to the users. It works from the form as originally designed. I just noticed it acting this way because I need to make some modifications, but can't until I can get it stabalized.

    I have compacted, repaired, decompiled, deleted other events (for now) ... what else should I try to debug this?

    Any suggestions are welcome.

    Best regards -


    ================================================== =======
    Private Sub txtComboTypeOfItem_LostFocus()
    Dim PNIEndValue As String
    Dim PNIStartValue As String

    PNIEndValue = "ICA"
    PNIStartValue = "PNI-Official Check"

    If PNIEndValue <> PNIStartValue Then
    If (Not IsNull(Me![txtCheckSerialNbr]) Or PNIEndValue = "PNI") And Me![txtComboTypeOfItem] <> "PNI-AMEX TC" Then
    Me![PNIInfo].Visible = True
    Me![Welcome].Visible = False
    End If

    If (Not IsNull(Me![txtCheckSerialNbr]) Or PNIEndValue = "PNI") And Me![txtComboTypeOfItem] = "PNI-AMEX TC" Then
    MsgBox "adding new code here."
    End If
    End If

    End Sub

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Evergreen, CO, USA
    Thanked 65 Times in 64 Posts

    Re: VB code flows randomly (2000)

    Unfortunately, I think we need more information to determine exactly what is going on with you code. It appears to me to be behaving more or less as I would expect, but there may be other code involved that is setting focus back to the control with retriggers the code with loss of focus, so you appear to have an endless loop.

    In particular, it would be useful to know if this is some sort of validation routine for a control. Also, it would be useful to know what the various referenced controls are supposed to represent. In particular these controls appear to be key:

    Have you tried stepping through it with the de###### to see if it appears to be behaving correctly? I suspect there is some other code getting in on the act.

  3. #3
    Gold Lounger
    Join Date
    Jun 2001
    Crystal Beach, FL, Florida, USA
    Thanked 41 Times in 40 Posts

    Re: VB code flows randomly (2000)

    Coud you perhaps move it to the controls AfterUpdate event and see what happens?
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts