Simple way to hide form controls and resulting white space

maw230

somewhat competent
Local time
, 18:34
Joined
Dec 9, 2009
Messages
522
I have a checkbox that determines whether or not to display certain form controls. How can I also hide the resulting white space that comes from hiding the form controls?

Can I put all of the controls in some sort of container and hide the container? The form objects are all displayed in order, so it shouldn't cause issue.

Can I create a subform for the objects and hide it? This would make the main and subforms based off of the same table.

Occam's Razor would be the preferred philosophy in this case. Nothing too fancy is needed.
 
Last edited:
i suspect you know this:

Me.ControlName.Visible = False

A reverse of the container Idea, could you cover the controls with a rectangle?
 
I tried the rectangle, but it didn't appear to "absorb" the controls. I put the controls within its boundaries and then hid the rectangle, but the controls remained.
 
Did you "Bring it to the Front" ?

Yes, didn't make a difference.

The white space issue is now the least of my worries. Now, I just need the form to requery the checkbox on record changes, so that it will hide the unneeded controls.

Here is the code for the checkbox. It's working fine when selecting and deselecting.
I just need the form to get the correct value from the checkbox for each record and act accordingly.

Code:
Private Sub chk_SingleLevel_AfterUpdate()
If (Me!chk_SingleLevel) = True Then

Me.txt_Batch_.Visible = False
Me.Line_Label.Visible = True
Me.Line.Visible = True
Me.Item.Visible = True
Me.Old_Price_Label.Visible = True
Me.Old_Price.Visible = True
Me.Alert_Price_Label.Visible = True
Me.Alert_Price.Visible = True
Me.New_Price.Visible = True
Me.New_Price_Label.Visible = True
Me.Region.Visible = True
Me.Region_Label.Visible = True


Else
Me.txt_Batch_.Visible = True
'Me.Item.Visible = True
'Me.Item_Label.Visible = True
'Me.Line_Label.Visible = False
'Me.Line.Visible = False
'Me.Item.Visible = False
Me.Old_Price_Label.Visible = False
Me.Old_Price.Visible = False
'Me.Alert_Price_Label.Visible = False
'Me.Alert_Price.Visible = False
Me.New_Price.Visible = False
Me.New_Price_Label.Visible = False
Me.Region.Visible = False
Me.Region_Label.Visible = False

End If


End Sub

And this is what I've tried for getting the form to requery the checkbox on the Current record. This isn't doing what I need it to.

Code:
Private Sub Form_Current()
Me.Form.Requery
Me.chk_SingleLevel.Requery


If (Me!chk_SingleLevel) = True Then

Me.txt_Batch_.Visible = False
Me.Line_Label.Visible = True
Me.Line.Visible = True
Me.Item.Visible = True
Me.Old_Price_Label.Visible = True
Me.Old_Price.Visible = True
Me.Alert_Price_Label.Visible = True
Me.Alert_Price.Visible = True
Me.New_Price.Visible = True
Me.New_Price_Label.Visible = True
Me.Region.Visible = True
Me.Region_Label.Visible = True


Else
Me.txt_Batch_.Visible = True
'Me.Item.Visible = True
'Me.Item_Label.Visible = True
'Me.Line_Label.Visible = False
'Me.Line.Visible = False
'Me.Item.Visible = False
Me.Old_Price_Label.Visible = False
Me.Old_Price.Visible = False
'Me.Alert_Price_Label.Visible = False
'Me.Alert_Price.Visible = False
Me.New_Price.Visible = False
Me.New_Price_Label.Visible = False
Me.Region.Visible = False
Me.Region_Label.Visible = False

End If
End Sub

Edit: Fixed by removing this line
Code:
Me.Form.Requery
. Although I feel like I tried this last week without that line at all, I can't be sure. :rolleyes:

Either way, it appears to be working now.

If anyone has suggestions on the white space let me know.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom