Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

yes no 1

Status
Not open for further replies.

Zorro1265

Technical User
Nov 14, 2000
181
US
How can I make a text statement appear based on the value of my yes no box.
Example
yes I would like the statement "normal" to appear in textbox named result.
no I would like to type in a stament into textbox named result.

Thanks for any info!
 
You just need a simple if statement on the 'after update' event of the yes/no box.

If me.yesornobox = true then
me.result = "normal"
else
me.result.setfocus
end if
Mike Rohde
rohdem@marshallengines.com
 
Thanks, perhaps you can help me with another question. I have a field in my form that I dont want a user to accidently change. I would like to send them a warning if the feild has data in it that they are about to change existing data. I thought an on enter event would work but I dont know how to make a message box appear giving them the option of backing out without changing things. Do you have any ideas?
 
You could just have a message box on the on enter or the on got focus event that warns them before they have a chance to change anything. Or maybe set the text box's enabled property to false and have a button that unlocks that textbox....

onclick
me.textbox.enabled = true.
Mike Rohde
rohdem@marshallengines.com
 
If you use an Enter or GotFocus event to interrupt the user with a message box, I hope this is the last field on the form, because otherwise they'll get annoyed with you every time they want to tab through to the next field without typing anything!

How about using the Change event instead? Then you won't interrupt them unless and until they really do try to change the data.

Example for a text box named "txtProtect"

In the form module Declarations section:
Code:
    dim boolArmed As Boolean
In the Form_Current event procedure:
Code:
    boolArmed = Not IsNull(txtProtect)
In the txtProtect_Change event procedure:
Code:
    If boolArmed Then
        boolArmed = False
        RunCommand acCmdUndo
        Beep
        MsgBox "Warning: You are about to change existing data!", vbExclamation
    End If

Whenever the user navigates to a record, the Current event procedure arms the warning message if the field is not blank. Then, when the first keystroke is hit to type into the field, the Change event procedure first disarms the warning (to allow subsequent typing to succeed), cancels the typing (with an Undo command) and then warns the user. By doing the Undo command first, the original data is restored so the user has a second chance to see what it was before it was changed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top