Link to home
Start Free TrialLog in
Avatar of clarwc
clarwc

asked on

Displaying records from two tables

I have two tables in an Access database (Personnel and Programs).  I need to use a DBCombo box to allow users to select an individuals code.  After the user selects the code from the DBcombo box I need to display data from the two tables.  There will be only one record from the "Personnel" table but multiple records from the "Program" table.  I also need to be able to delete individual records from the "Program" table without affecting the Personnel table.

Any code available will help

Avatar of fguerreiro_inix
fguerreiro_inix

Use two datacontrols, one for each table. The data controls
will have a where clause to identifie the person in cause.

Regards
Avatar of clarwc

ASKER

I am already using two data controls one for each table.  Each table already has a common field (Code).  I need the user to select the appropriate entry from the Code DBCombo and then have the screen update to reflect the single record from the personnel  Table and the multiple records from the Program table.

Thanks
So, what's your problem?
Avatar of clarwc

ASKER

When I select the code from the DBcombo nothing happens except changing data already displayed in the first record.  My application isn't taking the information from the DBCombo and displaying the records associated with the selection.

Thanks for your time.
So, what's your problem?
Avatar of clarwc

ASKER

Did you see my last?  I am not able to display the records associated with the selection.
clarwe,
Sound like you are new in dealing with this, so I am going to recommend a easy way.

I assume that your two tables has a comman field (say fieldCom) and you have established a one to many relationships between them (Personnel on the one side)

1. Drop a data control, name data1, set the databasename to your database, and recordsource to Personnel.

2. Drop a DBcombo box, name dbCombo1 set rowsource to data1, and listField to fieldCom

3. Drop a number of text boxes (equall to the number of fields in Personnel, set dataSource to data1, and  dataField to a field in the table

4. Drop a 2nd dataControl, name data2, set the dataBaseName to yur database  and datasource to Select * from Program where FieldCom = dbCombo1.Text

5, Drop a dbGrid, bound it to Data2.

6. In the dbCombo1's change event, add:
    data1.FindFirst fieldCommon = dbcombo1.Text
    data2.Refresh.

Try this. If you have hany questions or problems, let me know
Regards
Dalin
 
clarwc,
Strainge. When I first answer the question, none of you two's comments was show. After I submit, I saw the two comments:
from fg: "So What is your problem"
from you: " Did you see my last?"
Now I am seem the ones before that.

That is why my answer used some names not reflecting yours (like fields code)
Anyway, let me know you have any q.
Avatar of clarwc

ASKER

Dalin...

Looks like this might be exactly what I need except I don't have a Data2 property called datasource.  I have record source but the SQL string doesn't work there.

Thanks
clarwe,
Sorry for the mistake. I meant Recordsource.
Try to use the following SQL:

Select * from Program where FieldCom =
    'dbCombo1.Text';

Appologize for any inconvinience it may have caused.
Regards.
Avatar of clarwc

ASKER

Dalin,

I already have a significant amout of code written that is dependant on recordsourse being set to programs.  Is it possible to add the required statements in code somewhere?  It would sure make things a lot easier.

Thanks so much for your help.

Warren
ASKER CERTIFIED SOLUTION
Avatar of Dalin
Dalin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of clarwc

ASKER

Thanks very Much for your help.

Warren