|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
List box add to db
Hi,
Im a newbie and i basically have the following structure * a table called "consultant" with fields Id = autonumber (primary key) name = text aka .. etc etc * another table called "table1" with fields Id = autonumber (primary key) code = text desc = text at the moment they are linked in the relationships via the consultant table id and table1. Ie i wanting consultant to be assocaited with projects the problme is i want list boxes boxes for both consultant and project and just associate them together and add into table id field So basically ahve two list boxes one wiht consultant names (allready present in table) and another list box with allready created projects (presently created) and click a button which will add a chosen consultant to a chosen project and have the abiloity to add several consultants to 1 project. If anyone could help me with any code i would be greatful |
|
#2
|
|||
|
|||
|
Actually you won't need any code to do what you want. But first you will have to set up your tables correctly. Currently you have what appears to be two tables. Table Consultant which I gather contains all the names of your consultants. The second table Table1 has the list of your projects. Technically, you actually don't have a one to many relationship but rather a many to many relationship. One project can have many consultants...and one consultant can have many projects. To set up the many to many relationship you will need an intermediate table that will hold the primary key from each table as the one to many. In this intermediate table make your list box holding the names of the consultants for the primary key of the consultants table, and a list box for the project names for the primary key of your projects table. Set the record source of your form to this intermediate table and add your list boxes. Then selecting a project you can select your consultant and now you have one record with one project and one consultant. Go to a new record select the same project again, and you can add a different consultant...now you have one project with two consultants. Or you can do it the other way around...add your consultant and then your project. Go to another new record and select the same consultant again and add a different project. Now you have one consultant with two projects and one project with two consultants. You be able to find all consultants for a specific project..or find all the projects for a specific consultant with a simple query. No coding required or any command buttons.
lwells |
|
#3
|
|||
|
|||
|
Quote:
Thanks for your help so far That doesnt seem to work, i cant select a consultant and assign a project to them, i have an immdeiate table with one field the links to consuktlant id and project id which are both primarty keys. I have followed your instruction but i cant get it to work |
|
#4
|
|||
|
|||
|
Your intermediate table needs two fields plus the primary key field
AutoNumber - Primary Key ConsultantID ---->Linked to the Consultant table ProjectID ---->Linked to the Project Table lwells |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft Access Development > List box add to db |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|