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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is There a Way to Keep From Entering Text in a Textbox? 2

Status
Not open for further replies.

quest4

Technical User
Aug 27, 2001
735
US
Good afternoon. I have a dozen or so textboxes with cmdButtons next to each one of them. When a cmdButton, is clicked, the code will fill in the textbox with the correct data. That all works great, the problem is any one can just put a cursor in the textbox and enter data, correctly or incorrectly. Is there a way to prevent people from entering data in those textboxes and only letting the cmdButton enter the data? Thank you in advance for any assistnace.
 
you can have the text box to have a an edit of false and encode within your button to set the allow edit to true during the edit. After its edited you can reset the allowedit property to false.
 
Thoght ......... instead of using a cmd button and a text box, what about trying a combobox. Have the combobox off a table or query that lists only what you want and the Control Source set to the field you want to store the data in. Anything else placed in there won't be accepted.

HTH

An investment in knowledge always pays the best dividends.
by Benjamin Franklin
 
Thank you for the response, kphu. I looked thru the property sheet of one of the textboxes for something on edit and the only things I saw was, enabled and locked. Where do I set these edit properties? Thank you for the response, I appreciate it.
 
Hi!

Try using the enabled/locked thingies you found:
[tt]enabled = no/false
locked = yes/true [/tt]

(either code or in the property dialog should do).

HTH Roy-Vidar
 
Thank you for the response, mph1. The textbox is there primarily to Display the person who approved this section, and then there is alot of other code besides just putting the persons name in that textbox, but lets not go there for right now. Lets just said the work horse here is the cmdButton. Thank you again for the response.
 
Thank you for the response RoyVidar. So, if i understand this correctly, you set all of the textboxes enabled properties to NO. Then at the beginning of the OnClick events of the cmdButtons, I would add Me!Enabled = YES. At the end of the procedure you add Me!Enabled = NO, much like the way you would do SetWarnings, is that about right? Thank you again for the assistance.
 
Quest4,

the enabled property will work. so in your command button

add in:

beginning of your button code

"name of textbox".enabled = true

add in at the end of the code before the end sub

"name of textbox".enabled = false

Hope that helps.

 
Hi!

In my version, I'm allowed to set all controlls to:
[tt]enabled = no/false
locked = yes/true [/tt]

and still be able to assign values thru the command button. Try that first.

If that throws errors, then, as you (and kphu) suggest:

[tt]Me!txtBox1.enabled=true
Me!txtBox1.locked=false[/tt]

at the beginning of the routine (or at last before you add a value), then at the end, after the assigning, the opposit:

[tt]Me!txtBox1.enabled=false
Me!txtBox1.locked=true[/tt]

As I understood your initial post, noone should be able to alter values in the textboxes manually at all, and that's what I've taken under consideration in this suggestion.

(when using both enabled and locked, the controls "look normal" but doesn't allow any edit's)

Post back with any questions.

HTH Roy-Vidar
 
it seems to me that the locked property would be all you were interested in. If you set the locked property to false at the beginning of the onclick, enter your values, then set the locked property to true at the end of the onclick the user would never be able to enter anything in the textboxes, except what is entered when they click the command buttons...
 
Yes, I agree with you jimb0ne, using only the Locked property would suffice.

But none of us have offered guest4 any explanation for our preferences, so I'll do a short one;-)

When using both properties, as I've described above, the user is neither able to change anything nor select the controls.

Using only locked, then the user is able to select the control and the text within the control, but not to change it. It would also be necessary to change the tab stop property, should one want to avoid entering the control when tabbing thru the form.

I prefer the first method.

Roy-Vidar
 
quest4,

I had a similar problem myself. The fix is rather crude and simple but it works. The experts would probably shake in horror.

On one of my forms I have a text box that displays a warning message when certain criteria is met. The text box is normally transparent until the message is generated.

The problem was that if the operator moved the cursor over the hidden textbox area the cursor would change to the vertical bar (edit mode). To prevent any inadvertent text changes I created a command button; made it transparent, deleted its Event Procedure and expanded it to cover the entire text box. Now when the operator moves the mouse over the text box the cursor doesn't change from the arrow thus preventing any possibility of inadvertent text changes.

The warning message still works fine when commaned.

mondoray [ponder]
 
Hi

Some very inventive ways to make a text box behave like a label here, why not just use a label control ?

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Good morning, folks. Boy some really good ideas were posted last night. I will be installing them today and given them a work out. The dbase is in test right now. Thank you very much to all of you fine folks, I really appreciate it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top