Call form on the basis of parameters

  • Thread starter Thread starter Eric
  • Start date Start date
E

Eric

I try to call report on the basis of parameters but it gives error on
wherecondition. Another question is does the FormName is the name of
the form?

DoCmd.OpenReport "tbl_Event_Rpt", acViewPreview,
wherecondion:="([PPVOD_Date between #" & Forms.FormName.Date1 & " #
and #" & Forms.FormName.Date2 & "#)"

Thanks,
 
You've got an opening square bracket that you never close (plus you
misspelled "wherecondition")

wherecondition:="([PPVOD_Date] between #" & Forms.FormName.Date1 & " #
and #" & Forms.FormName.Date2 & "#)"

Note that in the event that some of your users have their short date format
set to dd/mm/yyyy, you're better off explicitly formatting the dates to
ensure they're interpretted correctly:

wherecondition:="([PPVOD_Date] between " & Format(Forms.FormName.Date1,
"\#mm\/dd\/yyyy\#") & "
and " & Format(Forms.FormName.Date2, "\#mm\/dd\/yyyy\#") & ")"

Yes, FormName would be the name of the form where the date fields are.

Note that your code requires that both Date1 and Date2 be provided: it will
not work properly if one or both values are missing.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top