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 / October 2005

Tip: Looking for answers? Try searching our database.

can't change focus to main form textbox

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rich1234 - 11 Oct 2005 10:04 GMT
I have a main form "A" with a subform "B." When a button, "lock/unlock" on
form A is pressed, one existing button on subform B is set to invisisble and
two other command buttons are set to visible.  
Here is the problem:
After one of these command buttons is pressed, another form "C" opens in a
new window where the user can view or edit data.   When the user returns to
the main form and subform "B" by closing form "C", the command button they
used to open form C still has the focus.. so when I click the lock/unlock
button on form A, I get the error, "You can't hide a control that has the
focus."

I know there are a few possible solutions to this one.  I want to change the
focus to a textbox, "VRM" on the main form A whenever the lock/unlock button
is pressed.  In VB for the lock button onclick event I have tried
Me.VRM.SetFocus
Me.Subform_B_Name.Form.Controls![CommandButton].Visible = IIf(bAllow,
"False", "True")

but it doesn't solve the problem.  The Me.VRM.SetFocus doesn't seem to have
any effect (in that the control previously pressed still generates the error.)
What am i doing wrong here?  Do I need to put something else before the
Me.VRM.SetFocus?  (Is it something to do with the fact that the buttons
hidden are in the subform and the lock button is on the main form?) There are
lots of things that are toggled between visible/invisible when the lock
button is pressed and rather than coding each one individually, I just want
to reset the focus to a textbox on the main form when the lock button is
pressed.

TIA
rich
Ofer - 11 Oct 2005 10:48 GMT
Try and set the focus to another object in the subform instead of the main form

Me.Subform_B_Name.Form.[Another Control Name that is visible].SetFocus
Signature

I hope that helped
Good luck

> I have a main form "A" with a subform "B." When a button, "lock/unlock" on
> form A is pressed, one existing button on subform B is set to invisisble and
[quoted text clipped - 26 lines]
> TIA
> rich
Rich1234 - 11 Oct 2005 11:11 GMT
Thanks for your suggestion Ofer.
Sometimes, the user wll be amending information in textboxes in the main
form (and not those in the subform) after clicking the ock/unlock  button.  
Is there a way to simply send forcus to the textbox VRM every time the
lock/unlock button is pressed?
thanks
rich

> Try and set the focus to another object in the subform instead of the main form
>
[quoted text clipped - 30 lines]
> > TIA
> > rich
Ofer - 11 Oct 2005 11:25 GMT
Try this
Me.Subform_B_Name.Form.[Another Control Name that is visible].SetFocus
Me.Subform_B_Name.Form.Controls![CommandButton].Visible = IIf(bAllow,
"False", "True")
Me.VRM.SetFocus

Signature

I hope that helped
Good luck

> Thanks for your suggestion Ofer.
> Sometimes, the user wll be amending information in textboxes in the main
[quoted text clipped - 38 lines]
> > > TIA
> > > rich
Rich1234 - 11 Oct 2005 12:47 GMT
Thanks Ofer.  I created an invisisble text box in the subform to temporarily
hold the focus during this process, as none of the controls are guaranteed to
be visible in all circumstances.

rich

> Try this
> Me.Subform_B_Name.Form.[Another Control Name that is visible].SetFocus
[quoted text clipped - 44 lines]
> > > > TIA
> > > > rich
 
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.