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 / New Users / March 2005

Tip: Looking for answers? Try searching our database.

[ASAP] GotFocus event

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Peter Schmitz - 01 Mar 2005 20:25 GMT
Hi,

in my current access vba project I have to set a textbox's '.text' property
to a specific value:

txtTest1.SetFocus
txtTest1.Text = ""

Now, when I run this code, the GotFocus handler of txtTest1 is called - how
can I prevent this? How can I erase a textbox's text property without calling
the GotFocus handler?

Thanks
Peter
Brendan Reynolds - 01 Mar 2005 20:37 GMT
Well, you can't. What you could do, though, is use a module level flag to
control whether code in the GotFocus event should run ...

mFlag = True
txtTest1.SetFocus
txtTest1.Text = ""

In the GotFocus event ...

If mFlag = True Then
   mFlag = False
   Exit Sub
End If

But why do you need to set the Text property? Is there a reason why you
can't set the Value property (which does not require that the control have
focus) instead of the Text property?

Signature

Brendan Reynolds (MVP)

> Hi,
>
[quoted text clipped - 13 lines]
> Thanks
> Peter
Peter Schmitz - 01 Mar 2005 20:51 GMT
Thanks for replying! All I want is to clear a textbox so that the user can
enter a new string. So, when I set value to "", does the textbox appear to be
empty?

Thanks
Peter

> Well, you can't. What you could do, though, is use a module level flag to
> control whether code in the GotFocus event should run ...
[quoted text clipped - 31 lines]
> > Thanks
> > Peter
Brendan Reynolds - 02 Mar 2005 11:27 GMT
Yup! :-)

Signature

Brendan Reynolds (MVP)

> Thanks for replying! All I want is to clear a textbox so that the user can
> enter a new string. So, when I set value to "", does the textbox appear to
[quoted text clipped - 40 lines]
>> > Thanks
>> > Peter
 
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.