Solved

Question about creating a SQL Statement

Posted on 1998-08-26
4
151 Views
Last Modified: 2010-04-30
I have the following tables and fields in an Access database
Appointments
    AppointmentID  (key field)
    OwnerID        (link field to other table)
    PetID          (link field to other table)
    AppointmentDate
Owners
    OwnerID     (key field)
    Name
Pets
    PetID       (key field)
    Name

What I need is a SQL Statement that will put them all together, ie so that I can refer to
.fields("Owners.Name")  and
.fields("Pet.Name")
0
Comment
Question by:PCav
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
lawnranger earned 50 total points
ID: 1431119
SELECT * FROM Appointments, Owners, Pets WHERE
Appointments.OwnerID=Owners.OwnerID AND
Appointments.PetID=Pets.PetID


0
 
LVL 1

Expert Comment

by:raygibbins
ID: 1431120
I would have used the following , it allow you to add records to the recordset if it is a dynaset

SELECT Owners.Owner, Pets.PetName, Appointments.AppontmentDate
FROM Pets INNER JOIN (Owners INNER JOIN Appointments ON Owners.OwnerID = Appointments.OwnerID) ON Pets.PetID = Appointments.PetID;

0
 
LVL 1

Expert Comment

by:lawnranger
ID: 1431121
raygibbins is right...if you need updateable and you are selecting from multiple tables you need JOIN.
0
 

Author Comment

by:PCav
ID: 1431122
Thanks Ray, but I already gave the points to lawnranger.  I don't need to update the records, just cycle through them and add the information to a listview control
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
I need help formating a date variable in my VB.Net application 2 52
Updates not working for MS Windows 7 12 166
MsgBox 2 55
TT Auto Dashboard 13 92
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

809 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