using a form to control show hide fields in a query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

i am looking for a way to cause fields in a datasheet subform to be added or
hidden if a check box is checked. i have a form that has a huge list of
records from a query and it would help if some columns could be hidden or
added to the results.
 
Here's an example ...

Private Sub Command5_Click()

Me.sfrOrders.Form.OrderID.ColumnHidden = Not (Nz(Me.Check1, 0))
Me.sfrOrders.Form.CustomerID.ColumnHidden = Not (Nz(Me.Check3, 0))

End Sub

This hides the 'OrderID' column if the check box 'Check1' is not checked,
and hides the 'CustomerID' column if the check box 'Check3' is not checked,
or shows them if the corresponding check boxes are checked.
 
Hello

THanks, and now a new question to add one more thing to the form.

how do i add a field for each column that would automatically filter the
results of the query?
 
Hi
I have the same issue, but forgive me, where do i put this code
I have approx 10 fields that i want to hide an a subform, unless a checkbox
is checked.
Actually i'd rather it be a button if possible,,,

But anway where exactly would i put the code and can i string the 10 fields
for the the 1 button or checkbox?

Please be specific as to where i put the code and how to sting it together
 
ok,
i finally figured out,, I put it in the Event Procedure of the 'on click'
for the checkbox and it is working!!!! yeee haaaaaah

I strung them altogether as shown below.


The only problem is i have to refresh the data after i check or uncheck in
order for anything to happen.

How can i get this to done automatically?
and again, i am a newbie so please if you could tell me exactly where i
need to put code, i would much appreciate it

thanks so much



Private Sub Weekly_Buy_Query_subform_Enter()



Me.Weekly_Buy_Query_subform.Form.Prime_Spots_Posted.ColumnHidden = Not
(Nz(Me.CheckboxPost, 0))
Me.Weekly_Buy_Query_subform.Form.Rot_Spots_Posted.ColumnHidden = Not
(Nz(Me.CheckboxPost, 0))
Me.Weekly_Buy_Query_subform.Form.Other_Spots_Posted.ColumnHidden = Not
(Nz(Me.CheckboxPost, 0))
Me.Weekly_Buy_Query_subform.Form.M.ColumnHidden = Not
(Nz(Me.CheckboxPost, 0))
Me.Weekly_Buy_Query_subform.Form.T.ColumnHidden = Not
(Nz(Me.CheckboxPost, 0))
Me.Weekly_Buy_Query_subform.Form.W.ColumnHidden = Not
(Nz(Me.CheckboxPost, 0))
Me.Weekly_Buy_Query_subform.Form.TH.ColumnHidden = Not
(Nz(Me.CheckboxPost, 0))
Me.Weekly_Buy_Query_subform.Form.F.ColumnHidden = Not
(Nz(Me.CheckboxPost, 0))
Me.Weekly_Buy_Query_subform.Form.Total_Calls.ColumnHidden = Not
(Nz(Me.CheckboxPost, 0))
Me.Weekly_Buy_Query_subform.Form.Actual_Total.ColumnHidden = Not
(Nz(Me.CheckboxPost, 0))
Me.Weekly_Buy_Query_subform.Form.Source_Num.ColumnHidden = Not
(Nz(Me.CheckboxPost, 0))


End Sub
 
ok,
i finally figured out,, I put it in the Event Procedure of the 'on click'
for the checkbox and it is working!!!! yeee haaaaaah

I strung them altogether as shown below.


The only problem is i have to refresh or move to another field in the form
after i check or uncheck the check box order for anything to happen.

How can i get this to done automatically?
and again, i am a newbie so please if you could tell me exactly where i
need to put code, i would much appreciate it

thanks so much



Private Sub Weekly_Buy_Query_subform_Enter()



Me.Weekly_Buy_Query_subform.Form.Prime_Spots_Posted.ColumnHidden = Not
(Nz(Me.CheckboxPost, 0))
Me.Weekly_Buy_Query_subform.Form.Rot_Spots_Posted.ColumnHidden = Not
(Nz(Me.CheckboxPost, 0))
Me.Weekly_Buy_Query_subform.Form.Other_Spots_Posted.ColumnHidden = Not
(Nz(Me.CheckboxPost, 0))
Me.Weekly_Buy_Query_subform.Form.M.ColumnHidden = Not
(Nz(Me.CheckboxPost, 0))
Me.Weekly_Buy_Query_subform.Form.T.ColumnHidden = Not
(Nz(Me.CheckboxPost, 0))
Me.Weekly_Buy_Query_subform.Form.W.ColumnHidden = Not
(Nz(Me.CheckboxPost, 0))
Me.Weekly_Buy_Query_subform.Form.TH.ColumnHidden = Not
(Nz(Me.CheckboxPost, 0))
Me.Weekly_Buy_Query_subform.Form.F.ColumnHidden = Not
(Nz(Me.CheckboxPost, 0))
Me.Weekly_Buy_Query_subform.Form.Total_Calls.ColumnHidden = Not
(Nz(Me.CheckboxPost, 0))
Me.Weekly_Buy_Query_subform.Form.Actual_Total.ColumnHidden = Not
(Nz(Me.CheckboxPost, 0))
Me.Weekly_Buy_Query_subform.Form.Source_Num.ColumnHidden = Not
(Nz(Me.CheckboxPost, 0))
 
Back
Top