I have been using the following code to cycle through a subform and disable all textboxes on a form. If a textbox on the form has the focus when this is run I get error "can't disable a control when it has the focus." When I add a line like "txtTest.SetFoc us" where txtTest is a textbox on the main form I still get the same error. How do I resolve this issue? Also, please note that I disable all controls on the subform. -
Private Sub EnableControls(ByRef frm As Form, ByRef CtrlTypeName As String, Enable As Boolean)
-
Dim nCount As Integer
-
For nCount = 0 To frm.Controls.Count - 1
-
If TypeName(frm.Controls(nCount)) = CtrlTypeName Then
-
frm.Controls(nCount).Enabled = Enable
-
End If
-
Next
-
End Sub
-
thank you for your time
8 5119 JKing 1,206
Recognized Expert Top Contributor
Have you tried setting focus to the form itself?
FishVal 2,653
Recognized Expert Specialist FishVal 2,653
Recognized Expert Specialist
is that really the best workaround? to create an empty option group and set borderstyle = transparent?
Another workaround may be to select current record before disabling last control -
DoCmd.RunCommand acCmdSelectRecord
-
ADezii 8,834
Recognized Expert Expert
I have been using the following code to cycle through a subform and disable all textboxes on a form. If a textbox on the form has the focus when this is run I get error "can't disable a control when it has the focus." When I add a line like "txtTest.SetFoc us" where txtTest is a textbox on the main form I still get the same error. How do I resolve this issue? Also, please note that I disable all controls on the subform. -
Private Sub EnableControls(ByRef frm As Form, ByRef CtrlTypeName As String, Enable As Boolean)
-
Dim nCount As Integer
-
For nCount = 0 To frm.Controls.Count - 1
-
If TypeName(frm.Controls(nCount)) = CtrlTypeName Then
-
frm.Controls(nCount).Enabled = Enable
-
End If
-
Next
-
End Sub
-
thank you for your time
If you're disabling all Text Boxes on a Sub-Form, simply disable the Sub-Form Control itself as in: - Me!subfChild.Enabled = False
If you're disabling all Text Boxes on a Sub-Form, simply disable the Sub-Form Control itself as in: - Me!subfChild.Enabled = False
this method doesn't shade disabled objects gray. i got a lot of feedback like "why can't i click on the text box"
ADezii 8,834
Recognized Expert Expert
this method doesn't shade disabled objects gray. i got a lot of feedback like "why can't i click on the text box"
You could 'mimic' the effect: - Dim ctl As Control
-
Const conNormal = 1
-
-
Me!subfChild.Enabled = False
-
-
For Each ctl In Me!subfChild.Form.Controls
-
If ctl.ControlType = acTextBox Then
-
ctl.BackStyle = conNormal
-
ctl.BackColor = 12632256
-
End If
-
Next
Many thanks! and amazed that this riddle is over. I was looking for a solution that solves a hypothetical prob, where a form consists of 1 text control and a label and when the Label is pressed, the text control is disabled.
After all, if MS access is workable, it's going to have to stand up with these basic features. The solution you provided (DoCmd.RunComma nd acCmdSelectReco rd) even with a form that doesn't consist a dataset, works.
I was trying to achieve similar results via setting attempting to set the screen.activeco ntrol to the form object itself. Of course it didn't set the focus to the Form like I was hoping it would; And I was hoping not to have to settle for anything less, like setting focus to arbitrary controls, or as one suggested Screen.Previous Conntrol via PreviousControl .SetFocus because a) makes the code unnecessarily messy and b) you'll need to have at least one other control that the focus can be set to, which doesn't cater for the above prob. @FishVal Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Els |
last post by:
Hi,
I would like an opinion on the following:
I have a page which is made up of background-images with transparent
linked images in front of it, which on hover show text in CSS popups.
Due to appropriate alt text, anyone viewing the page with images
turned off, will see the alt text instead, and on hover will see the
popups.
|
by: owen |
last post by:
Generally speaking, what does it mean when I see a "button" with red text
showing this message instead of the control I've dragged onto the web form
in Design View.? (But the page works fine at runtime). Does it indicate
a problem with References for example?
Thanks
Owen
PS. replies cc'd by email appreciated.
owen.southwood@mantix.com
|
by: galsaba |
last post by:
1. I want to have the value 01 if the number is 1
waht would be the function?
2. i think i need to use the function formatnumber.
Where can I find on the web the syntex of cstr( ,
formatnumber( ,
or any other function?
Thanks
|
by: Ken Yu |
last post by:
Hi,
How can i disable "RightClick Menu" in Internet Explorer, when
access the frontpage ?
tks a lot !
Ken
|
by: Ravi Ambros Wallau |
last post by:
Hey guys:
What can I do when an "Error Creating Control" is displayed on the form
(instead of the control), and a tooltip indicating the error never is
displayed?
Is there some log, some hidden message, some entry in registry where a
log is created (or that enables a log, trace, dump or whatever)...
I'm a little bit frustated with this error :-(
Tks,
Ravi.
| |
by: moi |
last post by:
Hello,
With ASP.NET 2 ,
i have two dropdownlist, one "A" (not in a formview) in the web page and other one "B" in a Insert Template in a formview. There's a link (parameter between this two dropdownlist.
When i selected a new item in the A dropdownlist, i have this error message :
Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control"
when i disable EnableStateView for the formview,...
|
by: Robert Jones |
last post by:
If my application doesn't have focus and someone clicks on the menu, the
menu click is "lost" as the form gets focus, and the user then has to click
on the menu a second time to actually activate the menu.
Is there a way for this focus click to be ignored and the menu to respond
immediately to the first click?
|
by: bhushan097 |
last post by:
hi ,
if you control user to right clik on page then why not is is possible to disable "save as" in file menu ?
plz suggest solution
Bhushan.
|
by: smith1966 |
last post by:
Please Help ...
I need to reference a particular control that exists on a "tabbed" page
eg
TABCtl5 has 3 "pages"
I have focus set to "TABClt5(Page-1)".
I need to access the content of a "text box" (named control-A) on "Page-3"
Within VBA ... How do I access access "Control-A" on "Page-3".
If I have focus set to "Page-1" ?
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |