-
Oct 25th, 2007, 03:32 PM
#1
Thread Starter
Addicted Member
detect if a combobox text has changed
Hello,
On a form I have a combobox that displays either YES or NO.
I also have a SAVE command button that saves any changes to a database, If the PAGE CLOSE command button is clicked, I need to detect if the YES NO text has changed and if it has been changed and the SAVE button has not been clicked, I need to display a message prompting the user to save.
I dont know how to detect if the combobox has changed when the user clicks the CLOSE button.
-
Oct 25th, 2007, 04:11 PM
#2
Re: detect if a combobox text has changed
I believe I understand the problem, but here's another scenario....
User has Combo = YES, and then clicks the save button, and then does more database changes. In what you are describing, you wouldn't catch this when Page Close occurs, or are there other checks you haven't described?
Assuming the above scenario can't happen, then an easy answer might be as follows. Another assumption: combo1 style is 2 (dropdown list)
1. At top of from add: Dim bDirty as Boolean
2. In your Save button click event: bDirty=False
3. In your combobox click event:
If Combo1.Text = "YES" Then bDirty=True Else bDirty=False
4. In your PageClose event:
If bDirty = True Then ' prompt for saving
Now if you have any other code that checks whether something changed that should be saved, then in that event/routine:
If Combo1.Text = "YES" Then bDirty=True
Tip: In any text boxes that contain field data, in the Change event, you can set bDirty=True to indicate something changed; your decision.
-
Oct 26th, 2007, 06:00 AM
#3
Re: detect if a combobox text has changed
Originally Posted by LaVolpe
Tip: In any text boxes that contain field data, in the Change event, you can set bDirty=True to indicate something changed; your decision.
This is referred to as a "dirty flag" and a method I've been employing for years.
-
Nov 9th, 2013, 12:45 PM
#4
Hyperactive Member
Re: detect if a combobox text has changed
Last edited by chris-2k; Nov 9th, 2013 at 04:00 PM.
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
|