-
March 14th, 2018, 03:24 PM
#1
Who does change?
I have forms with multiple controls. Most Controls when their property (for text box it's Text, for CheckBox it is Value etc.) is changed set the flag named blnDataChanged controlling the changes to TRUE. Based on that some other processes go different way (If blnDataChanged = True Then...). When form is loading and loads data to controls all controls set blnDataChanged = True and after loading blnDataChanged = False.
I'd like to run some process when any data in controls is changed by user, not by program. If I select using Key_Up, Key_Press or some other events I will need to write huge amount of code.
Is there any way to know who changes data in controls, user or program?
Thank you.
-
March 14th, 2018, 05:25 PM
#2
Re: Who does change?
A simple method
1: Create a flag var
2: Set it to false at the top of form load
3: In each change event check the flag and if false then ignore. If true then process
4: At the end of form load or wherever needed to activate the change events set the flag to true
Code:
Dim ChangesActive as Boolean
Private Sub Form_Load()
ChangesActive=False
' other stuff
ChangesActive=True
End Sub
Private Sub Text1_Change()
If ChangesActive Then
'Do stuff, set var or whatever
End IF
End Sub
Always use [code][/code] tags when posting code.
-
March 14th, 2018, 06:19 PM
#3
Re: Who does change?
Thank you. I was thinking about this method. It was the first idea I came to. But it requires me to write a lot of changes due to big number of controls plus their often repopulation invoking by different processes. I was hoping to find the way to distinguish who makes changes, the user or the program.
-
March 18th, 2018, 09:01 PM
#4
Re: Who does change?
Well, if you could really distinguish somehow between code or the user making the change, wouldn't you need to check that as well in each and every event handler, just like the flag suggested by DataMiser?
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|