Solved

Displaying records from two tables

Posted on 1998-06-08
13
154 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

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
 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

805 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