Results 1 to 3 of 3
Thread: VB code flows randomly (2000)
2003-05-20, 17:02 #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
If (Not IsNull(Me![txtCheckSerialNbr]) Or PNIEndValue = "PNI") And Me![txtComboTypeOfItem] = "PNI-AMEX TC" Then
MsgBox "adding new code here."
2003-05-20, 19:11 #2
- 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.Wendell
2003-05-21, 12:08 #3
- Join Date
- Jun 2001
- Crystal Beach, FL, Florida, USA
- Thanked 37 Times in 36 Posts