Predictive dialers generate profit

Menu
+ Free On-Line Tutorial

-Avoid #Error

-Customize 'Not In List' msg

-Programmatically add items to a combo box list

-Programmatically hide controls

-Security

MS Access Tools

About Us

Consulting Services




Tools, Add-ins, and Tutorials for Microsoft Access Developers 888-287-9497
linegld.gif

Question:
Why do I get an error when I try and programmatically hide a control? The error is "You can't hide the control that has the focus" I found a work around by setting the height and width of the control to 0, but is there a better way?

www.moretools.com

Solution:

Yes there is a better way. The reason you get this error is that the control you are trying to hide currently has focus. You have to move to another control to remove the focus and then set Command1.Visible=false.

** Bad Code **

Private Sub btnHide_Salary_LostFocus()

[Salary].Visible = False

End Sub

 

** Good Code **

Private Sub btnHide_Salary_LostFocus()

'Move to any other another control so that [salary] no longer has focus.

[First Name].setfocus

[Salary].Visible = False

End Sub


[Free On-Line Lessons] [ MS Access Tools ]  [Consulting] [About Us] [ Home ]


Copyright More Web Sales, LLC All Rights Reserved.
2245 N. Green Valley Parkway, #212
Henderson NV  89014 
orders@morewebsales.com
Office: 1-888-287-9497 (toll free)
Fax: 702-447-1401
International Callers