After further messing around I figured out that the sql in the qryQuickRpt
has to look like this:
SELECT tblCaseInfo.Region, tblCaseInfo.CaseId, tblCaseInfo.DHSNo,
tblCaseInfo.CaseName, tblCaseInfo.Action, tblCaseInfo.Vendor
FROM tblCaseInfo
WHERE (((tblCaseInfo.CaseId)=Any (select CaseId from qryQuickFrm)))
ORDER BY tblCaseInfo.CaseName;
I added the "Any"
But the form that opens from the qryQuickfrm, opens up after a dialog box
that has this code:
Dim stDocName As String
Dim stLinkCriteria As String
Dim varItem As Variant
stDocName = "frmQuickListOpen"
stLinkCriteria = "[tblCaseInfo]![Region] IN ("
For Each varItem In Me.RegionList.ItemsSelected
stLinkCriteria = stLinkCriteria & _
Me.RegionList.ItemData(varItem) & ","
Next varItem
stLinkCriteria = Left(stLinkCriteria, Len(stLinkCriteria) - 1) & ")"
If Me.RegionList.ItemsSelected.Count > 0 Then
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, "fdlgRegQuickOpen"
Else
MsgBox "Please select one or more regions and try again."
End If
So my subquery in qryQuickRpt does not work because the form is using the
above to open (I am launching the report from the form). So, do I need to
add a SQL statement to the On Click event to the Print my report button on
my form?
Shelly
Hi Steve:
I get this message when attempting to open the report or run then report
query [qryQuickRpt] :
"At most one record can be returned by this subquery"
and then nothing happens. The report never opens and the query never
displays any results.
Here is the SQL view of the report query [qryQuickRpt]:
SELECT tblCaseInfo.Region, tblCaseInfo.CaseId, tblCaseInfo.DHSNo,
tblCaseInfo.CaseName, tblCaseInfo.Action, tblCaseInfo.Vendor
FROM tblCaseInfo
WHERE (((tblCaseInfo.CaseId)=(Select tblCaseInfo.CaseId From
qryQuickFrm)))
ORDER BY tblCaseInfo.CaseName;
Here is the SQL from the qryQuickFrm:
SELECT tblCaseInfo.Region, tblCaseInfo.CaseId, tblCaseInfo.DHSNo,
tblCaseInfo.CaseName, tblCaseInfo.Action, tblCaseInfo.Vendor
FROM tblCaseInfo LEFT JOIN tblStatus ON tblCaseInfo.CaseId =
tblStatus.CaseId
WHERE (((tblStatus.ClosedDate) Is Null))
ORDER BY tblCaseInfo.CaseName;
Dunno what to do now . . .
Shelly
Hi Shelly,
Do it like this ---
You have a query (let's call it QryMyFormQuery) for your form that
should
include CaseID along with all the other fields that are there for
criteria
and/or to display in the form. The key here is to recognize that you
have
all
the CaseIDs you want in the report.
Create a query to base your report on and be sure to include CaseID.
Put
the
following expression in the criteria of CaseID:
In (Select CaseID From QryMyFormQuery)
Your report query will now return all the records where CaseID is in
QryMyFormQuery or in other words the same records as are in the form.
--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com
I have a continuous form that opens up after the user navigates a
series of
dialog boxes selecting criteria. I want the user to be able to print
the
resulting list. However, I cannot figure out the VB code to insert
the
form's filtered record set into a report. So, one possible