Solved

Run time error 3079 "The specified field could rever to more than one table listed in the FROM clause of your SQL statement

Posted on 2004-10-30
556 Views
Last Modified: 2008-01-16
Using VBA and writing my own SQL statements, I have three tables to extract data from.  

Key values are:
  tblPatientInformation.PatientID
  tblPulmonary.EvaluationID
  tblFunctionalImpairmentsMonitor.EvaluationID

I have done the appropriate relationships using the Relationships tool

The code.
'******************************************************************************
 'Construct SQL statement
Dim strSQL
strSQL = " SELECT PD.*, PI.PatientID, PI.LastName, FIM.O2_Sat_RA" + _
             " FROM tblPulmonaryDisease PD, tblPatientInformation PI, tblFunctionalImpairmentsMonitor FIM" + _
             " WHERE (PD.PatientID = PI.PatientID) And (PD.EvaluationID = FIM.EvaluationID) And " + _
              (PD.PatientID = "  
strSQL = strSQL + "'" + Me.textboxPatientID.Value + "'" + ") "
strSQL = strSQL + " ORDER BY PD.EvaluationID;"
'******************************************************************************

I get back the 3079 run time error.  Please help.

Thanks,
Jim Botts
jsbotts713@leaco.net
 
0
Question by:jbotts
    1 Comment
     
    LVL 18

    Accepted Solution

    by:
    Try this if PatientID is a number

    Dim strSQL
    strSQL = "SELECT PD.*, PI.PatientID, PI.LastName, FIM.O2_Sat_RA" & _
                 " FROM tblPulmonaryDisease PD, tblPatientInformation PI, tblFunctionalImpairmentsMonitor FIM" & _
                 " WHERE (PD.PatientID = PI.PatientID) And (PD.EvaluationID = FIM.EvaluationID) And " & _
                 " (PD.PatientID = " & Me.textboxPatientID.Value & ") ORDER BY PD.EvaluationID;"


    if PatientID is a string do this

    strSQL = "SELECT PD.*, PI.PatientID, PI.LastName, FIM.O2_Sat_RA" & _
                 " FROM tblPulmonaryDisease PD, tblPatientInformation PI, tblFunctionalImpairmentsMonitor FIM" & _
                 " WHERE (PD.PatientID = PI.PatientID) And (PD.EvaluationID = FIM.EvaluationID) And " & _
                 " (PD.PatientID = '" & Me.textboxPatientID.Value & "') ORDER BY PD.EvaluationID;"

    Mike
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Course: JavaScript Coding - Massive 12-Part Bundle

    Regardless of your programming skill level, you'll go from basics to advanced concepts in a vast array of JavaScript subjects including Sammy.js, Agility.js, Ember.js, Node.js, jQuery, AJAX, Extjs, AngularJS, Knockout.js, and JSON.

    This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
    When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
    In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
    In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

    884 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

    18 Experts available now in Live!

    Get 1:1 Help Now