Solved

Displaying records from two tables

Posted on 1998-06-08
13
153 Views
Last Modified: 2010-05-03
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

0
Comment
Question by:clarwc
  • 6
  • 4
  • 3
13 Comments
 
LVL 3

Expert Comment

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

Regards
0
 

Author Comment

by:clarwc
ID: 1462758
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
0
 
LVL 3

Expert Comment

by:fguerreiro_inix
ID: 1462759
So, what's your problem?
0
 

Author Comment

by:clarwc
ID: 1462760
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.
0
 
LVL 3

Expert Comment

by:fguerreiro_inix
ID: 1462761
So, what's your problem?
0
 

Author Comment

by:clarwc
ID: 1462762
Did you see my last?  I am not able to display the records associated with the selection.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 9

Expert Comment

by:Dalin
ID: 1462763
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
 
0
 
LVL 9

Expert Comment

by:Dalin
ID: 1462764
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.
0
 

Author Comment

by:clarwc
ID: 1462765
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
0
 
LVL 9

Expert Comment

by:Dalin
ID: 1462766
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.
0
 

Author Comment

by:clarwc
ID: 1462767
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
0
 
LVL 9

Accepted Solution

by:
Dalin earned 100 total points
ID: 1462768
clarwc,
The answer is yes.  You can utilize your code interms of dealing with the data (recordset)
The suggestion I provide basically populate the recordset for two data controls.
If you would like my opinion on where to add, I would need a little more information about what you are doing with the data and what kind of code you already have.. You can e-mail me:Dalin_N@MailExcite.Com

By the way, you don't have to reject the answer if you like what the expert provide you so far and just like to work with him a little more.

Regards
Dalin
0
 

Author Comment

by:clarwc
ID: 1462769
Thanks very Much for your help.

Warren
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now