Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / August 2005

Tip: Looking for answers? Try searching our database.

A2000 error "Can't access this property if control does not have focus"

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mr. Me - 02 Aug 2005 16:18 GMT
I have a text box. When my form opens, in the Form_Activate I init all my
text boxes to blank, like this:
text1.text=""

But each time I do I get an error "Cannot access this property if control
does not have the focus."

Did I init my fields in the wrong event?
Should I have put the init statements in the Form_Open instead?
How do I init my text boxes (and combo boxes) once when the form loads
without getting this error?

Thanks.

Signature

Sig: Say no to fixed width HTML tables. They look terrible in most browsers.

Allen Browne - 02 Aug 2005 16:39 GMT
Drop the .Text bit.

Unlike pure VB, in Access the default property of a text box is not .Text,
but .Value.

BTW, you may also want to set the value to Null, rather than a zero-length
string, i.e.:
   Me.Text1 = Null

You would not normally need to do this when loading a form: text boxes
default to Null. And you would probably not want to do this in the Activate
event of a form: if another form became active for a bit, when you activate
your original one again, you would lose all your values.

Signature

Allen Browne - Microsoft MVP.  Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

>I have a text box. When my form opens, in the Form_Activate I init all my
> text boxes to blank, like this:
[quoted text clipped - 7 lines]
> How do I init my text boxes (and combo boxes) once when the form loads
> without getting this error?
Baz - 02 Aug 2005 16:50 GMT
> I have a text box. When my form opens, in the Form_Activate I init all my
> text boxes to blank, like this:
[quoted text clipped - 9 lines]
>
> Thanks.

Don't refer to the text property.  Do this:

Me!text1 = ""

instead of this:

Me!text1.text = ""

Incidentally, why do you want to do this?  If the form opens at a new record
(e.g. because it's DataEntry property is set to True) then the controls will
all be blank anyway.  If it opens at an existing record, then doing this
will destroy the record!
Mr. Me - 02 Aug 2005 18:08 GMT
On Tue, 2 Aug 2005 16:50:10 +0100 in article <dco4ea$46j$1@news.e7even.com>,
bazz@REMOVEbcap.THEeuro1net.CAPScom spoke thusly...

> > I have a text box. When my form opens, in the Form_Activate I init all my
> > text boxes to blank, like this:
[quoted text clipped - 24 lines]
> all be blank anyway.  If it opens at an existing record, then doing this
> will destroy the record!

This form is not a bound form. It is not bound to a table and the text boxes
are not bound to fields. Thus I was concerned that when the form opened, all
the text boxes would have their default text, which is "Text1".

Thanks for the help!

Signature

Sig: Say no to fixed width HTML tables. They look terrible in most browsers.

Baz - 02 Aug 2005 18:22 GMT
> On Tue, 2 Aug 2005 16:50:10 +0100 in article <dco4ea$46j$1@news.e7even.com>,
> bazz@REMOVEbcap.THEeuro1net.CAPScom spoke thusly...
[quoted text clipped - 33 lines]
>
> Thanks for the help!

browsers.

Access text boxes don't have a default value of "Text1", or indeed anything.
Text boxes on an unbound form are blank!
Mr. Me - 02 Aug 2005 20:15 GMT
On Tue, 2 Aug 2005 18:22:14 +0100 in article <dco9qs$pug$1@news.e7even.com>,
bazz@REMOVEbcap.THEeuro1net.CAPScom spoke thusly...

> Access text boxes don't have a default value of "Text1", or indeed anything.
> Text boxes on an unbound form are blank!

Then I must be thinking of Visual Basic.

Signature

Sig: Say no to fixed width HTML tables. They look terrible in most browsers.

Baz - 03 Aug 2005 08:51 GMT
> On Tue, 2 Aug 2005 18:22:14 +0100 in article <dco9qs$pug$1@news.e7even.com>,
> bazz@REMOVEbcap.THEeuro1net.CAPScom spoke thusly...
[quoted text clipped - 3 lines]
>
> Then I must be thinking of Visual Basic.

Yes, you could be.  But even in Visual Basic, you can remove the default
text in the properties window at design time.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.