• Input Box (2000 SR1)

    Author
    Topic
    #358312

    First of all, I am trying to re-use an existing query for a second report and do not want to change the query. However, I would like this new report to run based off of an input box. What is the code that has a user type in their value into an input box and then uses that answer as the criteria for the query.

    Am I making sense?

    Viewing 0 reply threads
    Author
    Replies
    • #534341

      In your query, in place of a hard-coded selection criteria (such as =’FL’), use a prompt enclosed in brackets, something like =[Which state do you want?]. When this query is now run, it will pop the input box with the prompt “Which state do you want?”.

      • #534343

        Thanks for your help. However, if I make that change to the query it will change another report and I don’t want to touch that one.

        (I am trying to re-use the same query for 2 different reports.)

        • #534348

          use the Filter capability of the Report
          this example captures the Title to use as the criteria, however, if there is no criteria, then the Filter is turned off.

          Private Sub Report_Open(Cancel As Integer)
          Dim strFilter As String
          strFilter = InputBox(“Enter Title Criteria”, “Need Data”)
          If strFilter “” And strFilter ” ” Then
          Me.Filter = “[Title] = ‘” & strFilter & “‘”
          Me.FilterOn = True
          Else
          Me.FilterOn = False
          End If
          End Sub

          PaulF

          • #534349

            Yup, Paul’s got it. Paul’s post and my play time in mocking it up for you must’ve overlapped, and our methodology is slightly different, but I’m going to attach my dummy db anyhow. Do note that both of us have assumed that the 2d report will contain a subset of the first report.

          • #534357

            Paul and Shane,

            Thank you – it works great. It’s accomplishes exactly what I was trying to do.

    Viewing 0 reply threads
    Reply To: Input Box (2000 SR1)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: