473,789 Members | 2,876 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Shading text boxes when form is disabled

65 New Member
Hello,

When a textbox's enabled property is set to false it becomes shaded and is clearly disabled. When I set the form's enabled property to false the text boxes are disabled but still look the same. Is it possible to shade out the text boxes without setting each individual property? Or can I set the property of all objects on a form?

Thanks
Nov 3 '06 #1
5 2315
NeoPa
32,579 Recognized Expert Moderator MVP
Use the form :-
Expand|Select|Wrap|Line Numbers
  1. For Each ObjectVariable in Me.Controls
  2.     With ObjectVariable
  3.         If .ControlType = 109 then .Enabled = False
  4.     End With
  5. Next ObjectVariable
from the OnOpen event or wherever you want it to be set.
Nov 3 '06 #2
PEB
1,418 Recognized Expert Top Contributor
Yeah I agree with NeoPa this disables or enables all fields automaticlly.. You can use this code to automate your enabling or disabling of your form...

:)
Nov 4 '06 #3
freeskier
65 New Member
this gives me "compile error: invalid qualifier". it hangs up on the bolded line.I am trying to pass the form referral which i want disabled to the sub. i commented out the code which has been used in the past. i would like to make this a public sub after i get this to work because it will be used quite often.

Expand|Select|Wrap|Line Numbers
  1.     If IsNull(lstPlacements) Then
  2.         DisableObjects ("sfrmEntryPlacement")
  3.         'sfrmEntryPlacement.Enabled = False
  4.     Else
  5.         EnableObjects ("sfrmEntryPlacement")
  6.         'sfrmEntryPlacement.Enabled = True
  7.     End If
  8.  
  9. Private Sub DisableObjects(ByRef AlteredForm As String)
  10.  
  11.     For Each ObjectVariable In AlteredForm.Controls
  12.         With ObjectVariable
  13.             If .ControlType = 109 Then .Enabled = False
  14.         End With
  15.     Next ObjectVariable
  16. End Sub
  17.  
  18. Private Sub EnableObjects(ByRef AlteredForm As String)
  19.     For Each ObjectVariable In AlteredForm.Controls
  20.         With ObjectVariable
  21.             If .ControlType = 109 Then .Enabled = False
  22.         End With
  23.     Next ObjectVariable
  24. End Sub
  25.  
Use the form :-
Expand|Select|Wrap|Line Numbers
  1. For Each ObjectVariable in Me.Controls
  2.     With ObjectVariable
  3.         If .ControlType = 109 then .Enabled = False
  4.     End With
  5. Next ObjectVariable
from the OnOpen event or wherever you want it to be set.
Nov 7 '06 #4
NeoPa
32,579 Recognized Expert Moderator MVP
Expand|Select|Wrap|Line Numbers
  1. Private Sub EnableObjects(ByRef AlteredForm As String)
  2.     For Each ObjectVariable In AlteredForm.Controls
  3.         With ObjectVariable
  4.             If .ControlType = 109 Then .Enabled = False
  5.         End With
  6.     Next ObjectVariable
  7. End Sub
FreeSkier,

You need to define the 'ObjectVariable ' before use.
A simple form would be 'Dim ObjectVariable As Object'. However, I wouldn't use the name ObjectVariable in any real code.
I also noticed that you're passing a string as a parameter rather than the form object itself. In this case you need to resolve to the form within the routine. I've included that in the new version below.
Try this :-
Expand|Select|Wrap|Line Numbers
  1. Private Sub EnableObjects(ByRef AlteredForm As String)
  2.     Dim objThis As Object
  3.  
  4.     For Each objThis In Forms(AlteredForm).Controls
  5.         With objThis
  6.             If .ControlType = 109 Then .Enabled = False
  7.         End With
  8.     Next objThis
  9. End Sub
Nov 7 '06 #5
MMcCarthy
14,534 Recognized Expert Moderator MVP
You're passing AlteredForm as a String so I think you will need something like.

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub tmpcode(ByRef AlteredForm As String)
  3. Dim obj As Control
  4.  
  5.   For Each obj In Forms(AlteredForm).Controls
  6.     With Obj
  7.       If .ControlType = 109 Then .Enabled = False
  8.     End With
  9. Next
  10.  
  11. End Sub
  12.  
  13.  
Nov 7 '06 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

8
5709
by: schmendrick | last post by:
Is it possible to disable a control with Text (Textbox, combobox etc) but not have the text fade? I have a bunch of text boxes for a database, want them disabled till i hit the edit key, not a problem, cept they are kind of hard to read while disabled. thanks!
11
26327
by: Randell D. | last post by:
Folks, I have seven text boxes which will contain measurements - I would like the user to input their values in the order that I have listed the boxes. How can I therefore make an input type=text name=box2 a readonly while type=text name=box1 has a length of zero? This is for an intranet based application and I understand all the arguements and points that one has to consider in such that my server
6
1306
by: rked | last post by:
I have an order form with about a hundred textboxes saying 0. People change the zero to something else to tell quantity of field. I am submitting page via asp and cdo. Is there a function that detects changed text boxes and will only have those submitted? Here is address of page. http://www.marioncountyfl.org/emsasupplies.htm
3
3176
by: buck | last post by:
reports/ can we alternate formatting such as "no shading" and then "shading" for multiple records such as a phone directory in Access2000 reports
7
3114
by: Siv | last post by:
Hi, I have an MDI application that uses a generic "ShowPage" routine in a module that is called when I want to display a child form. The basic idea is that in the module I have declared each form as follows: Friend F0 As frmMain Friend F1 As frmStart Friend F2 As frmSearch Then in my ShowPage routine (which is passed a string "pageToShow" which is the name of the form I wish to open), I first check to see if we already have an instance...
2
2289
by: jarekz | last post by:
Hello friends. This is my first post here. Please forgive me any mistakes. Could you help me solve the problem that I have in MS Access 2003? I downloaded this template from Microsoft: http://office.microsoft.com/en-us/templates/TC010185811033.aspx and started working on it to modify it for my users' needs. At the bottom of the first page of the tab control I added a few text boxes and closed them within an option group. It's not a real...
6
12235
by: =?Utf-8?B?Sm9obiBBdXN0aW4=?= | last post by:
I have an app that displays about 20 items of data in text boxes. Very occasionally I need to allow these to be used for data entry, but the bulk of the time they are solely for information. They all sit in a GroupBox that is normally disabled, but is enabled when data can be edited. The users complain that when the GroupBox.Enabled=False, the greyed out text boxes are hard to read. I would like to find a way to disable the GroupBox whilst...
1
1405
by: Malinmore | last post by:
the following works well regarding one select box with one hidden text box. however I need two unique select boxes with relevant hidden text boxes that un-hide when the Add New option is selected. the problem is that the upper hidden text box always appears when the page is loaded. Can anyone tells me why? //physicianID function enableOtherPhysicians() {
1
2572
by: stewdizzle | last post by:
I have a from with three radio buttons (same group) and three text boxes. The radio buttons give the user a choice of uploading one, two, or three images. Currently, I have the text boxes load as disabled and the radio button selection enables the needed text boxes. It works but... I don't want to see the text boxes unless they are needed and I want the user to be able to change their mind. (ie choose three images or go back to one image)...
0
9511
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,...
0
10199
jinu1996
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...
1
10139
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9983
tracyyun
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...
0
9020
agi2029
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...
1
7529
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4092
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3697
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.