Results 1 to 6 of 6
  1. #1
    dkkirk2000 is offline Novice
    Windows 8 Access 2013 32bit
    Join Date
    May 2017
    Posts
    3

    Question Calculate or Input in field

    Hello everyone!!
    I'm pretty new to access but have been force to learn as I go to develop a database for my team. I've done pretty well so far, but usually run into walls, like now.



    I have a query in which I have a set of steps that are based on a provided date, so I give my query a date and it calculates backwards up to a final date, everything works well, but now I have to add a different type of change in which I need to input 2 dates in type A change but ignore in type B.
    So in the example below, I give a date at (330) for change B, dates calculates all the way thru (15). For change type A I give it a (330) date (no calculations) and a (140) date that calculates to (15). This is where I run into the wall..... I need to tell the query at (140) that if the Change type = B calculate, If change type = A let me enter date and calculate down to (15), Unfortunately I need the steps (330, 140,20...) to be call the same.

    Change type A Change type B
    (330) = date (330) = date
    (280) = (330) - 5d
    (270) = (280) - 7d
    (140) = date (140) = (270) - 3d
    (20) = (140) - 2d (20) = (140) - 2d
    (15) = (20) - 1d (15) = (20) - 1d
    Thank you for your help!!!

  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,652
    Personally, I don't like doing complex calculations in queries. I'd create a VBA function that had your logic in it, pass the date and type to it and let it return the result. A primer here if needed:

    http://www.baldyweb.com/Function.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    dkkirk2000 is offline Novice
    Windows 8 Access 2013 32bit
    Join Date
    May 2017
    Posts
    3
    thanks for the reply. I'm ok with using a VBA function, but how do I tell it that if change = A enter date, else ignore and calculate......?????

  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,652
    I'm not really clear on what you're doing now, or the requirement. Will it be different for each record? You could get a date from a form, an input box, or whatever is appropriate to your situation.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    dkkirk2000 is offline Novice
    Windows 8 Access 2013 32bit
    Join Date
    May 2017
    Posts
    3
    ok, let me rephrase: All I want to do is:
    If Change type is A: let the user input a date, if Change type is B: take the date on (270) and subtract 3 days.

  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,652
    Well, an input box in the VBA could let the user input a second date, but in a query I can see that being a pain in the rear. That's why I asked if it would be a different date for every A record. What does your query look like now?
    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: 3
    Last Post: 11-29-2016, 10:03 AM
  2. Calculate field
    By Vegaanders in forum Access
    Replies: 2
    Last Post: 06-13-2016, 04:28 AM
  3. Calculate Field Results
    By MFS in forum Queries
    Replies: 2
    Last Post: 11-10-2015, 01:11 PM
  4. populating field in form based on input field
    By BrandonFinn in forum Forms
    Replies: 7
    Last Post: 10-30-2014, 10:45 AM
  5. Replies: 5
    Last Post: 09-25-2014, 08:33 PM

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