Use VBA to set the subdatasheetname property

ma t

Registered User.
Local time
Today, 11:04
Joined
Mar 10, 2011
Messages
80
Hello all, I am not sure if this is possible or not, I am opening a query from a docmd.openquery action in a button... however, I would like to set the name of a sub query in VBA so that I can have one "main" query open with different sub queries. My main query is a "member roster" with basic person information, and the sub queries (linked on the person's id number) contain various other types of information.I have three different variations on the sub query, and I would like to reuse the main query and just change the sub query in code. Does anyone know who to do this?

This doesn't work- but its the general idea of what i am hoping for-

Code:
Private Sub cmdMembershipRoster_Click()
    DoCmd.Openquery "Rpt_MemberRoster", , subdatasheetname = "rpt_MemberHistory"

Thanks in advance,
 
Thank you Pat, i will research how to use a querydef. I am using the query/subquery because my users fine it helpful to be able to see a simple list of results with the subdatasheet not expanded, but easily expandable if they want to see the detail. I used to spend hours formatting reports and forms, but they prefer the simplicity of a datasheet.
 

Users who are viewing this thread

Back
Top Bottom