Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change appearance of disabled subform

Status
Not open for further replies.

yoshe

Technical User
Jan 12, 2007
36
US
Hello,
I have a subform that is disabled unless a field value is set to "yes". The caption above the subform is greyed out until the subform is enabled, but the appearance of the actual subform is the same whether or not it is enabled. Is it possible to grey out the subform when it is not enabled? Thanks for any suggestions.
 
Don't know that you can actually get it to work like that (I've had trouble doing that too) but you could maybe just have a gray box become visible over the top of it until it is enabled and then set the box to invisible. Just a thought.

Bob Larson
 
Like Bob said there is no single property for a form to make it look like a disabled control, but there are several ways to simulate it.

1) The easiest way without a lot of coding, would be to create your sub form. Call it something like "subFrmOne". Then when you are happy with its appearance and functionality copy it and call it "subFrmTwo". Make subFrmTwo look and act disabled, by changing colors of the form and controls. Now when you enable the subform set the source object of the subform control equal to subFrmOne and when you disable the control set it to subFrmTwo.

2) The second way would be to simply enable the control in code and have the method also change the colors of the form and the controls. Something like this

dim frm as access.form
dim cntrl as access.control
set frm = me.subFrmControlName.form
frm.detail.backcolor = somecolor
for each cntrl in frm.controls
cntrl.forecolor = somecolor
next cntrl

do the same with disable. The problem with this method is that if you have a lot of controls with different colors then getting them back to the default may require a lot of control specific instructions

3) If I was doing this I would build a custom class and custom collection. In this way regardless of how many controls I have with multiple formatting I could save the original control properties as a property of my custom class. Then I could change it to the disable settings, and then return to the original settings. This would work well but if you have not done this before there would be a lot of overhead involved.
 
I'd go with bob, just set the subform Visible property to false when you want it "disabled", and to True when you want it "enabled", and case solved - if they can't do anything with it, they probably don't even need to see it.

--

"If to err is human, then I must be some kind of human!" -Me
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top