Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2004

    Unanswered: One form to serve several report options


    I am hoping someone will have an answer and help me out. I have several forms with one list box that display the contents based on an underlying query. I also have one report coming off of each of these queries.

    On the form, I have provided a combo box to filter the report. Upon selecting from the combo box, the user clicks a button that opens another form (report mode selection) and also passes an openargs as part of it.

    The newly opened form gives two Case options: Preview and Print the filtered report (radio buttons) and a click button to confirm that then delivers the selection (preview or print) of the filtered report. This works via a custom function that builds a "where" clause, with the last click appending the where clause (the filter) to the two Case options.

    My problem is this: since a user could call a filtered report from any of the forms (and the specific report associated with it), my where clause append in the last click step has to accomodate each of the different arguments. The easy way is to create as many of the report mode selection forms as there are list box forms - but this is highly inefficient. I want to use the one form and for it to know which report, possibly by having another openarg (that identifies the report), in addition to the filter. But the DoCmd.OpenForm statement accepts only one openarg. How does one get around this?

    Thanks in advance.


  2. #2
    Join Date
    Feb 2004
    One Flump in One Place

    I think you are saying how can you pass multiple variables in a single variable? If so, you could delimit the string e.g. you pass the following through as the opening argument:

    "where statement and stuff;acViewPreview;reportname"

    Then have your button that opens the report parse the string:

    Dim strView As String
    Dim strRep As String
    Dim strWh As String
    Dim intStart As Integer
    Dim intEnd As Integer

    intStart = InStr(Me.OpenArgs, ";")
    strWh = Mid(Me.OpenArgs, 1, intStart - 1)

    intEnd = InStr(intStart + 1, Me.Text0, ";") - intStart
    strView = Mid(Me.OpenArgs, intStart + 1, intEnd - 1)

    intStart = InStr(intStart + intEnd + 0, Me.Text0, ";")
    strRep = Mid(Me.OpenArgs, intStart + 1)

    DoCmd.OpenReport strRep, strView, strWh
    You now have two billion characters worth of variables you can pass. Also, there is kind of another property you could use for a second opening args - the forms' tag property.
    Last edited by pootle flump; 05-07-04 at 19:45.
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Mar 2004

    Thanks a bunch for the help. I had to modify your script a little bit, but it works great!

    I have another question for you: the "report options" form that I mentioned (that has the selections to preview or print a report) actually has three - the third one being email the report.

    Unfortunately, unlike the preview/print which use the DoCmd.OpenReport (that allow the use of a where condition), the email command uses a DoCmd.SendObject that gives me no such option to insert a where clause.

    Obviously, if a filtered report needs to be emailed (ie, only the report pertinent to a manager is to be emailed), the where clause is as necessary as it is in the case of preview and print. How do I give this functionality?

    Thanks again in advance.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts