Microsoft Access Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft Access Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old January 24th, 2005, 11:26 AM
admanirv admanirv is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 3 admanirv User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 51 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old January 24th, 2005, 07:29 PM
lwells lwells is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Sep 2004
Posts: 632 lwells User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 21 h 59 m 38 sec
Reputation Power: 5
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

Reply With Quote
  #3  
Old January 25th, 2005, 05:44 AM
admanirv admanirv is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 3 admanirv User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 51 sec
Reputation Power: 0
Quote:
Originally Posted by lwells
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


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

Reply With Quote
  #4  
Old January 25th, 2005, 10:06 AM
lwells lwells is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Sep 2004
Posts: 632 lwells User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 21 h 59 m 38 sec
Reputation Power: 5
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

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft Access Development > List box add to db


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT