Results 1 to 4 of 4

Thread: Using Calculate Field in Same Query

  1. #1
    New Member
    Join Date
    Jul 2015
    Posts
    26
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Using Calculate Field in Same Query

    Hello,

    I have a very limited knowledge of Access and am struggling through and enjoying creating my first database. When in query design view, I created a field by entering the following formula into the field region:

    Lab$: [LabHours]*([CrewRate]+[OHRate])

    So when I switch to datasheet view, I get a new column that executes exactly what I want it to do.

    Question - can I in turn use Lab$ in the same query in which it was created? I am able to see it and use it when I create query 2 by using query 1 but I can't figure out a way to use it in the query 1.

    Thank you,

    Rob Schmidt

  2. #2
    MrExcel MVP
    Junior Admin
    Joe4's Avatar
    Join Date
    Aug 2002
    Posts
    50,765
    Post Thanks / Like
    Mentioned
    57 Post(s)
    Tagged
    11 Thread(s)

    Default Re: Using Calculate Field in Same Query

    Question - can I in turn use Lab$ in the same query in which it was created?
    Yes. Just refer to it like this in your next calculation: [Lab$], i.e.
    Code:
    Raise$: [Lab$] * 1.1
    TIPS FOR FINDING EXCEL SOLUTIONS
    1. Use the built-in Help that comes with Excel/Access
    2. Use the Search functionality on this board
    3. A lot of VBA code can be acquired by using the Macro Recorder.

    "Give a man a fish, feed him for a day. Teach a man to fish, feed him for life!"

  3. #3
    New Member
    Join Date
    Jul 2015
    Posts
    26
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Using Calculate Field in Same Query

    Thank you. I have tried that, as it makes logical sense but have run across multiple errors. This time I was told I had some aggregate something or other. Maybe it is just easier to have one query that does a slew of calculations and then do my secondary calculations in query 2 based off of query 1.

    The theory and logic behind some of the decisions I need to make seems very complicated. Any advice on understanding best practices?

  4. #4
    MrExcel MVP
    Junior Admin
    Joe4's Avatar
    Join Date
    Aug 2002
    Posts
    50,765
    Post Thanks / Like
    Mentioned
    57 Post(s)
    Tagged
    11 Thread(s)

    Default Re: Using Calculate Field in Same Query

    This time I was told I had some aggregate something or other.
    So, is this an Aggregate Query? If so, the rules may be a bit different. It probably depends on how it is all set-up.
    When posting questions like this, it is often helpful to post the SQL code of your query so we can get a better idea of all that is happening (you can do this by switching the query to SQL View and and copying and pasting the code here).

    Some advice is to not try to do too much within a single query (*especially if you are using the Query Builder to build it instead of writing the SQL code directly yourself). It can make it very complex and hard to understand, debug, and support. There is nothing wrong with using multiple queries for a task.

    *I have this caveat, because if you are proficient at writing SQL code directly, you can often used nested queries to do in a single query that which might otherwise take multiple queries. However, this is definitely a more advanced thing (for those who are comfortable writing SQL code).
    TIPS FOR FINDING EXCEL SOLUTIONS
    1. Use the built-in Help that comes with Excel/Access
    2. Use the Search functionality on this board
    3. A lot of VBA code can be acquired by using the Macro Recorder.

    "Give a man a fish, feed him for a day. Teach a man to fish, feed him for life!"

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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