• Open Form and pass a value as a parameter (Acess 2002)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Open Form and pass a value as a parameter (Acess 2002)

    Author
    Topic
    #383191

    I am trying to open a form to show the people contributing a particular monthly amount “curDiff ” which is calculated in a module.

    I have an existing form “frmShowContributions” to do this which is based on a parameter query to request which monthly contribution you wish to show.

    Ideally, I’d like to use this form and pass the value of “curDdiff” as the parameter. I was planning to use

    Docmd.OpenForm “frmShowContributions”

    I’m not sure how to do this though.

    Would I be better to create a new form and add a “Select” instruction? To the doCMd? Or is there an easier way?

    Thanks

    ****************************************
    Colin McDonald
    HYPERLINK “mailto:colinmac@blueyonder.co.uk”colinmac@blueyonder.co.uk
    ****************************************

    Viewing 1 reply thread
    Author
    Replies
    • #652675

      I believe that you can specify a criteria in the OpenForm command, have a look at the help on OpenForm.
      Pat cheers

      • #652843

        Online help gives virtually no detail, which is why I approached this forum.

        I tried this, using a form based on a standard (non-parameter query)

        DoCmd.OpenForm “frmShowContributions”, , , “Donation = curDiff”, acFormReadOnly

        This however still brings up a parameter dialog box. I then have to manually enter the amount.

        curDiff is a calculated variable.

        Colin

        • #652848

          Your report knows nothing about curDiff, so change your OpenReport statement to:

          DoCmd.OpenForm “frmShowContributions”, , , “Donation = ” & Me!curDiff, acFormReadOnly

          Pat cheers

    • #652729

      I would create a new form with a control to select the contribution you wish to show. If possible use a combo box.

      Then to open the form you have two options.

      One is to apply a filter. This assumes that the form you want to show is set up to show all records. By applying a filter as you open it you only show those that match the filter. The code is:

      DoCmd.OpenForm stDocName, , , stLinkCriteria

      The other option is to base the form on a parameter query that takes it parameter from the select form.

      In this case the query will have a criterion like this :

      [Forms]![frmSelectContribution]![Combo0]

      Both methods work OK. The filter method avoids creating another query.

      I attach a little sample with both methods.

    Viewing 1 reply thread
    Reply To: Open Form and pass a value as a parameter (Acess 2002)

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

    Your information: