Thingol
Technical User
- Jan 2, 2002
- 169
Hi all,
I am trying to make a smart selection using SQL in VBA.
I have an address database in Access 2000. I have a table in which relations are made between persons in the database and groups they can belong to. Each person can belong to any number of groups and each group can contain any number of persons. I have a form from which people should be able to easily manage the groups in which a selection of people should reside. Here's a picture of the form:
I want the user to be able to select the groups to which the selected persons shown in the lower listbox (the user has already made the selection of persons beforehand), should be added. The code should then figure out if any of the relations that the user wants to make are already present in the table with relations, if so, these relations do not have to be made, all the ones that do not exist yet should be made. A relationship exists if the combination of GroupID/PersonID already exists. PersonID can be taken from the lower listbox and groupID from the upper listbox.
Now I tried doing all sorts of code on this, but I think SQL is the easiest way of doing it. I haven't however managed to create a working piece of code.
My question is: can anyone give me any ideas on how to approach this? Be creative! If you need more information, then please, let me know!
Thanks a lot in advance for any feedback or suggestions.
Best regards,
Martijn Senden.
In the Beginning there was nothing, which exploded.
--Terry Pratchett, Lords and Ladies--
I am trying to make a smart selection using SQL in VBA.
I have an address database in Access 2000. I have a table in which relations are made between persons in the database and groups they can belong to. Each person can belong to any number of groups and each group can contain any number of persons. I have a form from which people should be able to easily manage the groups in which a selection of people should reside. Here's a picture of the form:
I want the user to be able to select the groups to which the selected persons shown in the lower listbox (the user has already made the selection of persons beforehand), should be added. The code should then figure out if any of the relations that the user wants to make are already present in the table with relations, if so, these relations do not have to be made, all the ones that do not exist yet should be made. A relationship exists if the combination of GroupID/PersonID already exists. PersonID can be taken from the lower listbox and groupID from the upper listbox.
Now I tried doing all sorts of code on this, but I think SQL is the easiest way of doing it. I haven't however managed to create a working piece of code.
My question is: can anyone give me any ideas on how to approach this? Be creative! If you need more information, then please, let me know!
Thanks a lot in advance for any feedback or suggestions.
Best regards,
Martijn Senden.
In the Beginning there was nothing, which exploded.
--Terry Pratchett, Lords and Ladies--