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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hiding/unhiding controls 1

Status
Not open for further replies.

BDawg04

Programmer
Jan 6, 2005
15
US
When my form opens only certain combo boxes show. I have set the others to show only after I click on the preceeding box. My problem is when there is data in one of the combo boxes that is hidden, it won't show. I have 4 boxes showing when the form loads. One of the records should show 5 boxes but it is only showing the 4 I initially set to open. How do I make that 5th box show on that record? I just want it to show how ever many boxes it needs to show for a particular record. If record 1 only needs 4 boxes, I only want the 4. If record 2 needs 6 boxes, I want those 6 to show, and so on. I'm really confused on this. I have played around with some things but can't get it to work. Any help is appreciated.
 
So do you only want to show these controls where they contain data for the current record?
 
Yes. That sounds right. I only want the control to appear if there is data to be displayed in the control for that specific record. Any help?
 
How about...

For each control in question, place something in the Tag property (i.e. "Display")

In the form's OnCurrent event.....
Code:
Dim ctl as Control
For each ctl in me
   If ctl.tag = "Display" Then
      ctl.visible = true
   Else
      ctl.visible = false
   End If
Next ctl




Randy
 
To simplify Randy's code:

Dim ctl as Control
For each ctl in me
ctl.Visible = ctl.Tag = "Display"
Next ctl
Set ctl = Nothing



Stewart J. McAbney | Talk History
 
A starting point, in the OnCurrent event procedure of the form:
[name of control].Visible = Not IsNull([name of control])

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
[blue]My problem is when there is data in one of the combo boxes that is hidden, it won't show.[/blue]
If visual for this combobox is dependent on wether the RowSource returns records, try the following ([blue]you![/blue] substitute the proper combobox name in [purple]purple[/purple]):
Code:
[blue]   Dim Ctl As Control, Cnt As Integer
   
   Set Ctl = Me![purple][b]ComboBoxName[/b][/purple]
   Cnt = Ctl.ListCount
   
   If (Cnt = 0) Or ((Cnt = 1) And (Ctl.ColumnHeads = True)) Then
      Ctl.Visible = False
   Else
      Ctl.Visible = True
   End If
   
   Set Ctl = Nothing[/blue]
[purple]If you having trouble placing the code, post back the code you have controlling visibility . . . .[/purple]

Calvin.gif
See Ya! . . . . . .
 
Thanks for the help. I had a few minor problems come up after I put the code from PHV in. However I think I might can figure them out. If not I may be back on here to look for some help. The other sets of code gave me an error. I have one control on my form that has the focus on the opening and it said it can't hide a control that has focus set. Thanks for all the input.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top