hoe to set focus on hidden textbox

Traden

Registered User.
Local time
Today, 20:52
Joined
Mar 7, 2003
Messages
32
how to set focus on hidden textbox

Hi,
i habe a form where i have a tb that checks if record is changed. It works fine when Tb is visible, but access tells me when i hide the textbox that it can not set focus to hidden textbox

Me.tbHidden.SetFocus

tbHidden is the name of my Textbox, it works fine when tb is visible but not when hidden. How to code that?

thanks
 
Last edited:
How does your tb check if the record has been changed, what's the purpose of it?
 
I don't actually see the point of the text box, I prefer to use a boolean, but your answer is to set the textbox visible to yes, set the tab stop to no and format the box fore/back/border colours etc. so that it appears invisible, won't work on a datasheet of course
 
thanks, but my problem is that the textbox named tbHidden changes value when changes in from appear. I agree boolean would be a good choice as well, but with my little knowledge coding VBA i just used the code i found. My problem is not to hide that text box, my problem is when i chosse visible "no" that i get an error message that tells me that access can not set focus on tb.hidden . i need that focus, because before saveing or going to a different record it checks the value of that textbox, if changes are made value is "no" and you will not be able to advanche before you either undo oder save.

so is there a different command to set focus on a textbox that is not visible?


thanks again for your patience
 
I don't see the problem, if you use the method I gave you the text box won't appear "visible"
 
Quite simply, you can't set the focus to a textbox that is hidden in the same way you can't make a textbox invisible when it has the focus.

Look at the SetFocus property in Access Help to find out why.
 
May I interrupt? ;)

The purpose of the tbHidden text box is to take the focus off any of the forms objects. It is a trick that I have been using for years. I code most of my forms events to set the focus back to the tbHidden text box. That just gives my forms a "clean" appearance so that none of the objects (command buttons) still have the focus after the command was processed. The visible property for the tbHidden text box is set to YES. The tbHidden text box is actually so small (Height & Width = 0.0097") that the user will never see it. I always put it in the upper left corner but for this example I moved it out a little bit so that you can "see" it in design view (just a little dot!).

As for the A better mouse trap? sample...

The trick is the value in the tbProperSave text box. The tbProperSave text box stores the Yes/No value. The visible property for the tbProperSave text box is set to NO.

Reading the forms code in the A better mouse trap? sample should detail how everything works for the process is very simple yet effective. The user can not move off of a dirty (modified) record unless they click one of my custom command buttons.

HTH
 
i need that focus, because before saveing or going to a different record it checks the value of that textbox, if changes are made value is "no" and you will not be able to advanche before you either undo oder save.
You don't need to set focus to a text box to reference it. If you are having a problem, it is because you are using the .text property. Don't use the .text property unless you know what you are doing. Look it up in help and make sure you understand the difference between .text and .Value. Value is the default property and can be ommited when referencing a control. Therefore:

Me.SomeField.Value is equivalent to Me.SomeField
 

Users who are viewing this thread

Back
Top Bottom