setfocus and accessing a text box

swarv

Registered User.
Local time
Today, 14:31
Joined
Dec 2, 2008
Messages
196
All,

I have a text box on a form and I would like the following code to read it

Code:
 userloggedon = Forms.frm_homepage.user_id.Text

This is fine if the box is visible, if the box isn't visible then it wont read it.
I would like the box not visible to the user but still be able to read it.
Is this possible?

Thanks

Martin
 
That's because Text requires that the control have focus, and you can't set focus to a control that's not visible!

Repalce

userloggedon = Forms.frm_homepage.user_id.Text

with

userloggedon = Forms.frm_homepage.user_id.Value

Because Value is the default property of textboxes, you can actually simply use

userloggedon = Forms.frm_homepage.user_id

In Access VBA, as opposed to straight Visual Basic, the Text property is very seldom used.
 
Don't use the .Text property. Use the .Value property, which is the default property and need not be specified.
userloggedon = Forms.frm_homepage.user_id
...or...
userloggedon = Forms.frm_homepage.user_id.Value
 
many thanks guys - that helps lots. I'll just edit some code.

cheers
 

Users who are viewing this thread

Back
Top Bottom