Hello there,
I am building an Access application to store information of Investments Funds and their Restrictions. There is more than one Fund and more than one Restriction. Each Fund can have multiple restrictions and each restriction can be attached to more than one Fund. So I created the following tables:
G_Funds (Meta information about the Funds)
M_Restrictions (Meta information about the Restrictions)
R_Restrictions_Funds (cross-refrence table)
In R_Restriction_Funds I store all the combinations of Funds and their Restrictions. On my Form the user can maintain de attached restrictions by moving the restriction between the two listboxes:
.listRestrictionsAttached
.listRestrictionsNotAttached
To populate the first one, I successfully use the following Query:
Not I want to populate the other listbox with alle the restrictions which are not in de result of the above Query. Thanks to this forum I found the function "NOT IN", but I am not sure how to implement this. Now, I've got the following Query but it simply does not work! This the other Query.
Question: What is wrong the the above. I simply miss it. I've got a solution with a do while loop, but of course, that is not a nice way of filling a listbox. Any help appreciated. An example of how to use the NOT IN statement in this case would be very benificial too. Thanks in advance.
Kind regards,
I am building an Access application to store information of Investments Funds and their Restrictions. There is more than one Fund and more than one Restriction. Each Fund can have multiple restrictions and each restriction can be attached to more than one Fund. So I created the following tables:
G_Funds (Meta information about the Funds)
M_Restrictions (Meta information about the Restrictions)
R_Restrictions_Funds (cross-refrence table)
In R_Restriction_Funds I store all the combinations of Funds and their Restrictions. On my Form the user can maintain de attached restrictions by moving the restriction between the two listboxes:
.listRestrictionsAttached
.listRestrictionsNotAttached
To populate the first one, I successfully use the following Query:
Code:
SQLa = "SELECT R_Restrictions_Funds.ID, M_Restrictions.ID As [Id#], M_Restrictions.Code, " & _
"M_Restrictions.Description, M_Restrictions.NumberOfVariables As Variabelen " & _
"FROM R_Restrictions_Funds INNER JOIN M_Restrictions ON R_Restrictions_Funds.ID_Restriction = M_Restrictions.ID " & _
"WHERE R_Restrictions_Funds.Id_fund = " & IdFonds
.listRestrictionsAttached.RowSource = SQLa
Not I want to populate the other listbox with alle the restrictions which are not in de result of the above Query. Thanks to this forum I found the function "NOT IN", but I am not sure how to implement this. Now, I've got the following Query but it simply does not work! This the other Query.
Code:
SQLb = "SELECT R_Restrictions_Funds.ID, M_Restrictions.ID As [Id#], M_Restrictions.Code, " & _
"M_Restrictions.Description, M_Restrictions.NumberOfVariables As Variabelen " & _
"FROM R_Restrictions_Funds INNER JOIN M_Restrictions ON R_Restrictions_Funds.ID_Restriction = M_Restrictions.ID " & _
"WHERE R_Restrictions_Fund.Id_fund NOT IN (" & SQLa & ")"
.listRestrictionsNotAttached.RowSource = SQLb
Question: What is wrong the the above. I simply miss it. I've got a solution with a do while loop, but of course, that is not a nice way of filling a listbox. Any help appreciated. An example of how to use the NOT IN statement in this case would be very benificial too. Thanks in advance.
Kind regards,