Re: problem with form...

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Thanks... this should work.
But I have a problem getting my code right in the DoCmd.OpenReport in the
WhereCondition

in the queries that I did, the criteria was I used
WHERE ((([intervention hydrant].[Date interv])=(SELECT MAX (tmp.[Date
interv]) FROM [intervention hydrant] as tmp WHERE tmp.[hydrant id] =
[intervention hydrant].[hydrant id])) AND (([intervention
hydrant].[Functional])=True));

for the case where I'd like to get the functional hydrant at the latest date
of intervention

how do I write this in the DoCmd.OpenReport?

Thanks again!



"Nikos Yannacopoulos" wrote:

> If i get this right, the fields are always the same, and what changes is
> the filters? If yes, you only need one report, and one query, or no
> (saved) query at all. Set the report's recordsource to your table or
> single saved query, and in the code behinf the command button on the
> form which opens the report, construct a Where statement, based on the
> user's selections on the form; then use this string in the
> WhereCondition argument in the DoCmd.OpenReport.
>
> On your other question, Also, put this code in the report's On No Data
> event:
>
> msg = "No data exists for the chosen criteria."
> typ = vbExclamation
> ttl = "Report cannot be generated"
> MsgBox msg, typ, ttl
> Cancel = True
>
> This will produce a message for the user and cancel opening the report,
> if there is no data.
>
> HTH,
> Nikos
>
.



Relevant Pages

  • Re: Query criteria that isnt bound to a single form or report
    ... Megan, to make it flexible, leave the criteria out of the query. ... use the WhereCondition of OpenReport. ... Each form can then build its own critiera, and re-use the same report. ...
    (comp.databases.ms-access)
  • Re: Create Report Using Form Parameters
    ... It might be easier to omit the WHERE clause from the query, and build a string to use in the WhereCondition of OpenReport. ... The last one applies its filter to a form, but creating the filter string for a report is identical. ...
    (microsoft.public.access.forms)
  • Re: Selections on Report
    ... If the report is based on a Totals query, you can use this technique on the fields that have Group By in the Total row in query design. ... If you need to be able to do that, you can either use a mix of both techniques (the WhereCondition for the Group By fields, and the query parameters for the Where fields), or you can build the entire SQL statement in the Open event of the report, and assign it to the report's RecordSource. ... There's a downloadable example that shows how to make a search form like ...
    (microsoft.public.access.reports)
  • Re: How to get around "filter too long" run-time error?
    ... Instead of using the wherecondition argument, ... the OpenReport method to pass the name of a saved query. ... you to filter a report without limitation on the size of the WHERE clause. ... How do I save a query from the form with the selected list items? ...
    (microsoft.public.access.formscoding)
  • Re: Populating a list -- table structure?
    ... I had made a report already and figured out about adding the ... your responce below, but thanks to your help with SQL, I was able to get the ... It takes a summary from a select query and gives the ... KitID, long integer ...
    (microsoft.public.access.forms)