Results 1 to 12 of 12
  1. #1
    George is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Feb 2012
    Posts
    295

    Querying a formula based field

    Good night,



    I have a field in my query which returns results based on a formula that is a function of other fields. The results are: Pass and Fail.

    I want to make a query that returns only Fail rows. When I enter Fail as the criteria, a parameter box pops up requesting information be entered before continuing.

    How can this problem be rectified?

    George

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,643
    Switch to SQL view and change the alias to the formula. In other words

    WHERE Alias = Fail

    to

    WHERE YourFunctionHere = Fail
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    George is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Feb 2012
    Posts
    295

    Unsure

    Thank you for your response but I am not clear. Here is my actual query : ON Programs.[Program Code] = [Class by Course].[Program Code]) ON Courses.[Course ID] = [Class by Course].[Course ID]
    WHERE (((Programs.[Prog Name])=" Child Care & Nursery Management.cert") AND ((IIf([Remarks]>40 And [Remarks]<50,"Supplimental",IIf(nz([Remarks])<41,"Repeat","")))="Repeat"));

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,643
    Well, that's part of an actual query. I don't see anything that says Pass or Fail there. What exactly does the parameter prompt say?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    George is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Feb 2012
    Posts
    295

    Query

    Pardon me - I gave a simplified scenario using fail and pass. In actual fact it was "Repeat" and "Supplemental". The actual parameter prompt says: Remarks.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,643
    Is Remarks a field in the table? If it's an alias for a calculated field, the calculation needs to replace it in the WHERE clause.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    George is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Feb 2012
    Posts
    295

    Query

    Thank you. Yes, remarks is a field, but it has a very long formula. Also every time this field is changed it would need updating in the where clause and this can lead to errors especially since copy and paste does not work.

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,643
    Because of the order in which the clauses are evaluated, you can't use an alias in the WHERE clause. Perhaps your simplest solution is to leave this query without the criteria, then create another query based on this one and have the criteria there. That way you can use Remarks in the criteria.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    George is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Feb 2012
    Posts
    295

    Query

    Thanks. It sounds feasible, but for me it might be challenging to make a query from a query. I would try and if I am unsuccessful I would check the forum again

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,643
    Easy as pie. When it shows you the list of tables you can add, there's a tab for queries. From there out there's no real difference.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  11. #11
    George is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Feb 2012
    Posts
    295
    Thanks again. It worked. My first time trying something like this.

  12. #12
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,643
    No problemo!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 12-22-2012, 12:38 PM
  2. Replies: 2
    Last Post: 09-26-2012, 04:22 AM
  3. Replies: 2
    Last Post: 09-18-2012, 07:51 PM
  4. Querying All Data When Form Field Is Blank
    By jre1229 in forum Queries
    Replies: 25
    Last Post: 08-22-2012, 11:32 AM
  5. Total based on Formula based on field value
    By cjbuechler in forum Reports
    Replies: 15
    Last Post: 07-10-2009, 09:56 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums