Solved

The specified field could refer to more than one table listed in the FROM clause of your SQL statement

Posted on 2006-10-25
2
508 Views
Last Modified: 2012-05-05
I get the message above when I try to open a form using a control button on another form.  The form being opened is frmTrainee and its query's SQL looks like this:

SELECT tblTrainees.StaffTrainingID, tblTrainees.StaffID, tblStaff.StaffLastName, tblStaff.StaffFirstName, tblTrainees.TrainingID, tblTrainees.TTBookedBy, tblTrainees.StatusID, tblTrainees.TTBooked, tblTrainees.TTBeforeLetter, tblTrainees.TTAfterLetter, tblTrainees.TTAssessment, tblTrainees.TTAssessmentReminder, tblTrainees.TTAssessmentReceived, tblTrainees.TTAssessmentNotes, tblTrainees.TTCertificate, tblTrainees.TTUpdateReminder, tblTrainees.TTUpdateBooked, tblTrainees.TTRef, tblTrainees.FunderID, tblTrainees.TTFundingAgreed, tblTrainees.TTFundingAmount, tblTrainees.TTInvoiceAmount, tblTrainees.TTFundingInvoicePay, tblTrainees.TTFundingInvoiceSent, tblTrainees.TTFundingPaid, tblTrainees.TTFundingNotes, tblTrainees.TTNotes
FROM tblStaff RIGHT JOIN (tblTrainees LEFT JOIN tblTraining ON tblTrainees.TrainingID = tblTraining.TrainingID) ON tblStaff.StaffID = tblTrainees.StaffID
ORDER BY tblStaff.StaffLastName, tblStaff.StaffFirstName, tblTraining.TrainingDate DESC;

The code for the control button that opens frmTrainee is:

    Dim stDocName As String
    Dim stLinkCriteria As String

  stDocName = "frmTrainee"

  'Open training records for this staff member
 If DCount("*", "tblTrainees", "[StaffID]=" & Me![StaffID]) <> 0 Then
         stLinkCriteria = "[StaffID]=" & Me![StaffID]
         DoCmd.OpenForm stDocName, , , stLinkCriteria
 
 'If there are none then create a new training record for this staff member
   Else
         DoCmd.OpenForm stDocName, acNormal, , , acFormAdd
         Forms!frmTrainee!StaffID = Me![StaffID]
    End If

The same form also has a control button that opens frmTraineeProgramme (which has similar code to the above except that it says frmTraineeProgramme and tblTraineeProgramme in the relevant places) but that one works fine.  I'm puzzled.  Any ideas?

0
Comment
Question by:Ludique
  • 2
2 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 17809007
Hi Ludique,
>          stLinkCriteria = "[StaffID]=" & Me![StaffID]
Try changing this line to:

         stLinkCriteria = "tblTrainees.StaffID=" & Me![StaffID]


0
 
LVL 61

Expert Comment

by:mbizup
ID: 17809025
Glad to help ;-)
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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 the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

758 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

23 Experts available now in Live!

Get 1:1 Help Now