Hide Column/Field In query based on checkbox

Okay, I get it. (And thanks for clearing that up. We don't mind if you post elsewhere we just like to know about it so we volunteers aren't double timing in our spare time.)

Unfortunately, there no *easy* way to do this with a check box. Deleting the column(s) might be but will still require some code. That said, you could just separate queries, not THAT would be easy.
 
Unless I am reading this completely wrong you are making it way to hard. You are not dynamically picking different fields to show. You want two queries, one has X fields the other has X-3 fields. Forget about deleting fields, simply make two queries. If you want a checkbox, or toggle button, or combobox whatever. You choose something and pick which query to load. If it is shown in a subform simply change the source object of the subform.
 
You are 100% correct.....making it way to hard. Here is all I have for my button click:

Code:
Private Sub cmdRunQuery_Click()

If Me.ckboxTrustAnnuityInfo = -1 Then
DoCmd.OpenQuery "qryListExportTrustInfo", acViewNormal
Else: DoCmd.OpenQuery "qryListExport", acViewNormal
End If

End Sub

I just copied my original query, renamed it and kept the fields I wanted and in the original query deleted the ones I didn't.

Just one more question....
The code above actually opens the query as a datasheet. If I want it to export directly to excel, which DoCmd do I use? Would DoCmd.Transferspreadsheet work?


Thank you every one here who contributed, it all gave me food for thought and suggestions to research
 
yes use docmd.transferspreadsheet. no need to open the query
 

Users who are viewing this thread

Back
Top Bottom