Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2007
    Posts
    4

    Unanswered: How to display a form after a query

    I have a query based on a data entry form,

    The query does some finding and calculations and determine the percentage of what product is
    left positive or negative.

    How do I get the query to check for >+5% and <-5% (what is good is between +5% and -5%)
    then display a form I created. To meet the condition.

    maybe an If statement if result >+5 and <-5 display form good else form bad

    I want the query to be able to display a good form and bad form.

    Any suggestions out there?

  2. #2
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820
    your best bet would be to run the query in a form and then build a VBA macro that will close the form and open the correct one, as far as i'm aware the only other option is to build a macro that calls the query inside itself and then opens the form.

    you can attach a query to a Macro or Form but you can't attach a Macro or Form to a query
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

  3. #3
    Join Date
    Jan 2007
    Posts
    4

    Talking

    Can you get me started in all this?
    Point me in the right direction.
    In others words walk me throught it step by step.....

  4. #4
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    you have a query 'myQuery' which does some stuff and ends up with a single % result in field 'pcCalc'.
    this query runs as a result of some event myEvent() in form 'frmEntry'
    depending on the % result you want to open 'frmGood' or 'frmBad'

    since you are only running this once in a while when an entry form has been completed (as opposed to in a loop), there is no heavy speed penalty in using an aggregate function.

    so try:
    private sub myEvent()
    dim myPercent as ...what are you using?
    'blah
    'blah
    'blah ...whatever you wanted to happen before the good/bad decision
    myPercent = dfirst("pcCalc", "myQuery")
    if myPercent < -5 or myPercent > 5 then
    docmd.openform "frmBad"
    else
    docmd.openform "frmGood"
    endif
    docmd.close acform, "frmEntry"
    end myEvent

    izy
    currently using SS 2008R2

  5. #5
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820
    thanks for that izy saved me some explaining
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

  6. #6
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    hellooooooooo ???
    did it work?
    izy
    currently using SS 2008R2

Posting Permissions

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