Results 1 to 6 of 6
  1. #1
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Edinburgh, Midlothian, Scotland
    Posts
    492
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    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@blueyon der.co.uk
    ****************************************

  2. #2
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

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

    I believe that you can specify a criteria in the OpenForm command, have a look at the help on OpenForm.
    Pat <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  3. #3
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

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

    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:
    <pre>DoCmd.OpenForm stDocName, , , stLinkCriteria</pre>


    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 :
    <pre>[Forms]![frmSelectContribution]![Combo0]</pre>


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

    I attach a little sample with both methods.
    Attached Files Attached Files
    Regards
    John



  4. #4
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Edinburgh, Midlothian, Scotland
    Posts
    492
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    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

  5. #5
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Edinburgh, Midlothian, Scotland
    Posts
    492
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    I'll have a look at this.

    Thanks


    Colin

  6. #6
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

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

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

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

    Pat <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

Posting Permissions

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