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
DoCmd.OpenForm stDocName, acNormal, , , acFormAdd
Forms!frmTrainee!StaffID = Me![StaffID]
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?