after/before update txtbox

benjamin.weizmann

Registered User.
Local time
Today, 05:14
Joined
Aug 30, 2016
Messages
78
hi , I have this sub:

Private Sub mach_2_AfterUpdate()
If Me.ex2 .value= 99999 And Not Me.mach_2.Value = 0 Then
If msgzeropro = 0 Then
Me.mach_2.Value = 0
Exit Sub
Else
Me.ex2.Value = msgzeropro
End If
End If
Call colordec(2)
End Sub

when msgzeropro and colordec are functions
this sub create kind of loop

cause in the first .. the user update the txtbox and call sub((1))
and in accordance condition , the sub update the textbox and call itself ((2))

how can I avoid ((2))??

I thought some ideas like static variable (but I have some txtbox with same sub) - so, I can not wait to hear your creativeness

:)

thanks
Ben

thanks u
 
Add a Boolean variable to the procedure e.g blnFlag

Set the value true when the value is updated.
Add a further condition so the sub only runs when blnFlag is False

Remember to reset the value to false after use.
 
Add a Boolean variable to the procedure e.g blnFlag

Set the value true when the value is updated.
Add a further condition so the sub only runs when blnFlag is False

Remember to reset the value to false after use.


sorry I don't think it 's the solve in this case..
or more exactly, maybe I don't know to operate it

I'll give u the full details :


Private Sub mach_1_AfterUpdate()

If Me.ex1.value = 99999 And Not Me.mach_1.Value = 0 Then
If msgzeropro = 0 Then
Me.mach_1.Value = 0 (***)
from now, everytime the user updates mach_1 I want this sub to occur
but not for this assign (***)

Exit Sub
Else
Me.ex1.Value = msgzeropro
from now, the sub will not be called and it's ok
End If
End If

Call colordec(1)
End Sub






thanks
 

Users who are viewing this thread

Back
Top Bottom