Originally Posted by
Goochag
That's not a bad idea Xipooo.
What type of vba code would I have to do to perform both of those actions? Maybe just an example just to help me grasp the concept would be great.
Well using a listbox is easy as pie. You can use the Query field names as your headers for the listbox. So all you would need is the VBA which swaps out the rowsource and does a requery on the listbox. All your headers would autopopulate with the field names. Nothing you aren't already doing really.
If you NEED subforms, then you will want to make a subform for each and every query you want to offer. Then in the combobox the value that gets returned should be the name of the subform you want to view. From there you just run a sub like this that goes through your list and makes all the subforms invisible, but then sets the one selected to visible.
Code:
private sub showSubForm()
dim x as integer
for x = 0 to me.<combobox>.ListCount - 1
me(me.<combobox>.ItemData(x)).Visible = False
next
me(me.<combobox>.Column(0)).Visible = True
end sub
That's assuming the values in your combobox are the names of the subform controls. It's a little trickier if you want to have a more generic value that is visible to the user, but the subform name is in a hidden column on the combobox. The above code would just have to be altered to used Column(1) for both the values of the subforms to hide and the one to show.
Honestly I don't really like this approach. If you can do it in a listbox, that would be far more preferable and faster.