Suggestions:
1. Add the # delimiter to the date.
2. Omit the query name from the WhereCondition string.
3. If you need to include the table name, use square brackets around the
table name and the field name separately, i.e.
[Distributors].[DistID]
4. The subform is not open in its own right, i.e. it will not be found in
the Forms collection. If it is a subform of the form where you are writing
this code, you can refer to it as:
Me.[NameOfYourSubformControlHere].Form![NameOfYourControlHere]
If not, use:
Forms![NameOfYourMainFormHere]
in place of the Me.
5. Create a separate string, so you can Debug.Print the results, and check
them in the Immediate Window after it runs. (Press Ctrl+G.)
6. Brackets are optional, but can help.
7. Use IsNull() to check if there is a value in the 2 controls.
8. Save any edits in progress before you open the report.
The result will be something like this (without the null tests):
Dim strWhere As String
If Me.Dirty Then Me.Dirty = False
strWhere => "([DistID] = " & Me![DistID] & ") AND ([DatePaid] = " & _
Format(Me.[frm-DistDetailSubform].Form![DatePaid],
"\#mm\/dd\/yyyy\#") & ")"
Debug.Print strWhere
DoCmd.OpenReport stDocName, acViewPreview, , strWhere

Signature
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
> To begin with - thank you - you are all so helpful with all of your
> knowledge.
[quoted text clipped - 22 lines]
>
> Thanks, Sarah
Sarah - 30 Dec 2005 15:54 GMT
Alan,
Thank you for your detailed explanation. I was able to plug the code in and
it worked perfectly (after I removed the > sign after the first =).
Thanks, Sarah
> Suggestions:
>
[quoted text clipped - 58 lines]
> >
> > Thanks, Sarah