Select case fraVal
Case 0
Docmd.openquery "qsQry0"
Case 1
Docmd.openQuery "qsQry1"
End select
To show or hide different columns of a datasheet you use the undocumented property "columnHidden"How do I display different columns (it is datasheet view) based on option selected?
Public Sub hideColumns()
Dim lst As Access.ListBox
Dim frm As Access.Form
Dim itm As Variant
Dim I As Integer
Set frm = Me.subFrmQueries.Form
Set lst = Me.lstChoose
Call showColumns
For Each itm In lst.ItemsSelected
frm.Controls(lst.ItemData(itm)).ColumnHidden = -1
Next itm
End Sub
Public Sub showColumns()
Dim lst As Access.ListBox
Dim frm As Access.Form
Dim itm As Variant
Dim I As Integer
Set frm = Me.subFrmQueries.Form
Set lst = Me.lstChoose
For I = 0 To lst.ListCount - 1
frm.Controls(lst.ItemData(I)).ColumnHidden = 0
Next I
End Sub
I would normally persist this data to a table (selected columns and column widths, frozen columns) so it is not an issue.re @MajP hiding columns. I believe that with an .de database, the design change doesn't persist as the form design change can't be saved. I think this affects users changing column width's as well. Please let me know if this isn't correct.
fldParentID | ParentRelation | ParentTitle | ParentFirstName | ParentLastName | fldHomePhone | ParentMobilePhone | ParentWorkPhone | fldEmail | fldEmail2 |
---|---|---|---|---|---|---|---|---|---|
93 | Father | Mr | Michael | Shell | 123-456-7890 | 456-789-1234 | 654-789-1234 | something@some.net | some@some.com |
93 | Mother | Mrs | Debbie | Shell | 123-456-7890 | 678-901-2345 | 876-901-2345 | something@some.net | some@some.com |
It depends. There are different ways to do things. If these all had the same columns then I would have one subform and change its recordsource. I could have wrote code to show and hide certain columns and still have only one subform, but that may not be as easy for most people. Much easier to design a subform. Having more forms and reports and queries is not a problem if you have a very good naming convention so you can manage them. Also the navigation pane has features to manage such as grouping objects and hiding objects.As a side point - would you always advise using this method which would mean adding more queries and subforms to database. Is there any downsides to having a database chockful with objects