Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to pass multiple values to parameter in Access?
    primarykey
    data
    text
    <h1>Background / Overall goal</h1> <ul> <li>I have an excel spreadsheet, with a list of items that certain roles need to test out. <ul> <li>Roles have members</li> <li>Roles can have member roles, which have their own users.</li> </ul></li> <li>I need to grab the total number of users who could test a given feature to grab names and count numbers for some metrics.</li> <li>I put the users, roles, and member roles into an Access DB for some quick querying</li> <li>Now, just trying to get the proper information out. I don't mind entering a list of roles and having it spit things back that way.</li> <li>I'd like to avoid adding all the test items for each role to the DB (there are a lot of them and this is supposed to be a reasonably quick task).</li> </ul> <h1>DB Structure</h1> <pre><code> +---------------+ +------------+ |RolesUsers | |Roles | |---------------| +---------------+ |+-----------| |ID | |Users | +-+|ID |+---+|RoleID | |---------------| | |RoleName | |UserID |+--+|ID | | +------------+ +---------------+ |UserName | | +---------------+ | | +-----------------+ | |RolesMemberRoles | | |-----------------| | |ID | +-+|RoleID | +-+|MemberRoleID | +-----------------+ </code></pre> <h1>Goal</h1> <ul> <li>Pass a list of roles to a query (either through a listed parameter or string list)</li> <li>Return a count of unique users who belong to any of those roles or any of their member roles</li> <li>Quick and dirty -- doesn't have to be fancy</li> </ul> <h1>Current Access Query</h1> <ul> <li>Returns users belonging to a role or its member roles for a given role entered via parameter</li> </ul> <blockquote> <pre><code>PARAMETERS p_RoleName Text ( 255 ); SELECT Roles.RoleName, Users.UserName FROM (RolesUsers INNER JOIN Users ON RolesUsers.UserID = Users.ID) INNER JOIN Roles ON RolesUsers.RoleID = Roles.ID Where RolesUsers.RoleID In (Select ID from Roles where Roles.RoleName = p_RoleName) UNION SELECT Roles.RoleName, Users.UserName FROM (RolesUsers INNER JOIN Users ON RolesUsers.UserID = Users.ID) INNER JOIN Roles ON RolesUsers.RoleID = Roles.ID Where RolesUsers.RoleID IN ( SELECT RolesSubroles.SubRoleID FROM RolesSubroles INNER JOIN Roles ON RolesSubRoles.RoleID = Roles.ID where Roles.RoleName = p_RoleName); </code></pre> </blockquote> <h1>Ideas So Far</h1> <ul> <li>Found <a href="http://datapigtechnologies.com/blog/index.php/passing-multiple-values-to-one-parameter/" rel="nofollow">an interesting post</a> on how to pass a string of text into a where clause using Instr(). Not sure how I could necessarily tweak that to my situation though.</li> </ul>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload