Hiding subform column based on combobox entry

MCatz

Access Dummy
Local time
Today, 17:43
Joined
Feb 21, 2011
Messages
49
Basically,

If a user selects "Yes" in a combobox, the subform appears and a certain column is hidden, but if he/she selects "No", the column is visible.

What's the best way to go about this?
 
Thanks for the response, Pbaldy.

Should I put the code in the AfterUpdate of the form or the subform (I tried both, but it didn't seem to do anything)? Also, how can I refer to the column I want hidden?

Here's what I tried

Code:
If Me.cmbPrecision = "Yes" Then
Me!sbfrmEquipResults.[Further Problems].ColumnHidden = True
Else
Me!sbfrmEquipResults.[Further Problems].Column Hidden = False
End If
 
Hi ya,

I take it you mean a column in a listbox if so

Just change the column width you want to hide to 0 cm

eg
Me.ListBoxName.ColumnWidths = "1 cm; 0 cm;3 cm"
will leave columns 1 and 3 visible

don't forget to refer to the sunform first (you already have the code for that above)

Take care
SmallTime
 
Sorry got the wrong end of the stick

Here we go:

Uasge Example: Forms![Form1]![Form2].Form![txt1].ColumnHidden = True
Form1 is main form
Form2 is subform
txt1 is field name for column that will be hidden

Also remove the space between 'Column' and 'Hidden'

Put the code in the after update event of the combo box

Take Care
SmallTime
 
That did the trick SmallTime! Thanks!

One last thing I'm trying to get.

How can I get a listbox to clear based on the value in a combobox?

If the choice is "Yes", any selections previously made in the listbox will be cleared.

I tried this in the "AfterUpdate" event on the Yes/No combobox to no avail:

Code:
If cmbPrecision.value = "1" Then
lstProblems.value = Null
End If
 
Presuming it's multiselect, you have to spin through it:

Code:
  Dim ctl           As Control
  Dim i             As Integer

  Set ctl = Me.lstCharges

  For i = 0 To ctl.ListCount - 1
    ctl.Selected(i) = False
  Next i
 
Good deal. Worked perfectly.

Thanks, guys.
 

Users who are viewing this thread

Back
Top Bottom