Hi-
I have a contact table in Access 2021 that holds contact emails and the various distribution lists they are subscribed to. I'd like to make a "List Generator" form where a user can select 1 or more distribution list name(s) from a list box then hit a button to generate a list containing the Email_address and Dist_List name(s) to be exported to Excel. The list box names correspond to the distribution list field names in the contact table.
Below is the select query that would run for each selection in the listbox:SELECT t_Contacts.Email_Address, "Dist_Newsletter" AS Dist_List
FROM t_Contacts
WHERE (((t_Contacts.Email_Address) Is Not Null) AND ((t_Contacts.Dist_Newsletter)="Subscribed"))
I need help creating the VBA to 1) set the list box selection as a variable to be inserted into the SQL where it is bold/red, and 2) combine all the selects into one big UNION ALL query. I just have no idea how to do it LOL. Any help would be so appreciated from this noob. Thanks in advance!