Results 1 to 11 of 11
  1. #1
    Join Date
    Oct 2010
    Location
    NJ, USA
    Posts
    9

    Due Date Form question

    Hey there, got a new question about Access 2007.

    I've been asked to start a new database for tool calibration records. I've entered all my information in two tables (Tool Calibrations, Calibration Certs); the one I'm more concerned with is the Tool Calibration table and form.



    My fields are:
    - Serial Number
    - Calibration Date
    - Next Calibration Date
    - Tool Type
    - Tool Range

    I want to make a form that will either:
    1. Possibly entering a date (or date range) and tell me which tools will be up for "Next Calibration Date" on that day (ex. [we use 3-month calibration schedules] if I put in "9/29/10", it would return, with the field from "Next Calibration Date" the 12/29/10 tools).
    2. List all possible tools needed form calibration in the following week (would be ideal, but I doubt possible).

    I know a query is needed, but what I can't figure out is how to specifically display the results on a relevant form. Once again, my VBA is lacking, so I figure there is a code I can use, but I don't know it.

    Thanks in advance,
    Acme Gear Steve

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    If it's always 3 months, there's really no need to save the next date; it can be calculated from the calibration date. If you still want to do it, in the after update event of the calibration date field:

    Me.NextCalibrationDate = DateAdd("m", 3, Me.CalibrationDate)

    Listing the upcoming items is fairly easy. A query with a criteria like:

    Between OneDate And AnotherDate

    would do it, and you can use functions from here to automatically get the following week:

    http://www.pacificdb.com.au/Support/...kfunctions.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    slave138's Avatar
    slave138 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Oct 2010
    Location
    WI
    Posts
    233
    As for your number two request, I would probably create a tool table with a Yes/No field for each calibration test. Then you could just query the table for any true values for a given test.

    I'm sure there are other ways it can be done depending on how everything is setup.

  4. #4
    Join Date
    Oct 2010
    Location
    NJ, USA
    Posts
    9
    Quote Originally Posted by pbaldy View Post
    If it's always 3 months, there's really no need to save the next date; it can be calculated from the calibration date. If you still want to do it, in the after update event of the calibration date field:

    Me.NextCalibrationDate = DateAdd("m", 3, Me.CalibrationDate)

    Listing the upcoming items is fairly easy. A query with a criteria like:

    Between OneDate And AnotherDate

    would do it, and you can use functions from here to automatically get the following week:

    http://www.pacificdb.com.au/Support/...kfunctions.htm
    Thanks for the response pbaldy, after thinking about it, I think you may be right. Since we do use 3-month calibration periods, there's no need to make it more complicated than it needs to be.

    So for this
    Code:
    Me.NextCalibrationDate = DateAdd("m", 3, Me.CalibrationDate)
    I just tacked it onto a RowSource for a ComboBox, making it:
    Code:
    SELECT [ToolCalibration Query].CalibrationDate FROM [ToolCalibration Query] 
    ORDER BY [ToolCalibration Query].CalibrationDate, [CalibrationDate] 
    AND DateAdd("m",3,CalibrationDate);
    This works, and it prompts me for a "CalibrationDate", but when I put in the Cali-Date it just gives me a drop-down box of all the Current Calibration Dates.

  5. #5
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    You need a criteria as I mentioned. How about this untested SQL:

    SELECT DateAdd("d",90,CalibrationDate) FROM [ToolCalibration Query]
    WHERE DateAdd("d",90,CalibrationDate) Between (Date() + (7 - Weekday(Date() , 2)) + 1) And (Date() + (7 - Weekday(Date() , 2)) + 7)
    ORDER BY DateAdd("d",90,CalibrationDate)

    I assume you'd want to add a field to identify the unit.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    Join Date
    Oct 2010
    Location
    NJ, USA
    Posts
    9
    Quote Originally Posted by pbaldy View Post
    You need a criteria as I mentioned. How about this untested SQL:

    SELECT DateAdd("d",90,CalibrationDate) FROM [ToolCalibration Query]
    WHERE DateAdd("d",90,CalibrationDate) Between (Date() + (7 - Weekday(Date() , 2)) + 1) And (Date() + (7 - Weekday(Date() , 2)) + 7)
    ORDER BY DateAdd("d",90,CalibrationDate)

    I assume you'd want to add a field to identify the unit.
    So, I dropped that code into an SQL Query, and at first I got a "Circular Reference", I figured it was because the name of the Query was in the FROM line, so I changed it to "FROM [ToolCalibration]" (I tried to make it [ToolCalibration Table], but it didn't like that much, so I assume ToolCalibration by itself assumes a table unless otherwise specified).

    When I open the query now, the only field I get is "Expr1000", but I don't even see that in the coding itself, so I couldn't figure out where it was from.

  7. #7
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    That's a default alias. If you go back into SQL view, you'll see:

    SELECT DateAdd("d",90,CalibrationDate) AS Expr1000 FROM

    In design view you'd see

    Expr1000: DateAdd("d",90,CalibrationDate)

    In either place you can change that to a description with more meaning to you, like ExpireDate.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    Join Date
    Oct 2010
    Location
    NJ, USA
    Posts
    9
    Alright, thanks for that.

    I've messed around with it and got to:

    Code:
    SELECT ToolCalibration.[DateAdd("d",90,CalibrationDate)] AS CurrentCalibration, DateAdd("d",90,[CalibrationDate]) AS NextCalibration
    FROM ToolCalibration
    WHERE (((DateAdd("d",90,[CalibrationDate])) Between (Date()+(7-Weekday(Date(),2))+1) And (Date()+(7-Weekday(Date(),2))+7)))
    ORDER BY ToolCalibration.[DateAdd("d",90,CalibrationDate)];
    There are now two issues I'm having. 1. I get a pop-up requirement first for "ToolCalibration.DateAdd("d",CalibrationDate)" . I feel like it's not picking up the data from the Table. And 2. I can't type anything in my CurrentCalibration Box, it says it's based on an expression and can't be edited.

  9. #9
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    It is an expression, due to the DateAdd() function:

    ToolCalibration.[DateAdd("d",90,CalibrationDate)] AS CurrentCalibration

    The popup is because with the table name at the beginning, it thinks you're telling it that is a field in the table, which it can't find. I think you want:

    ToolCalibration.CalibrationDate AS CurrentCalibration
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  10. #10
    Join Date
    Oct 2010
    Location
    NJ, USA
    Posts
    9
    Quote Originally Posted by pbaldy View Post
    It is an expression, due to the DateAdd() function:

    ToolCalibration.[DateAdd("d",90,CalibrationDate)] AS CurrentCalibration

    The popup is because with the table name at the beginning, it thinks you're telling it that is a field in the table, which it can't find. I think you want:

    ToolCalibration.CalibrationDate AS CurrentCalibration

    Alright, thanks for the help. I'll try and figure it out from here; don't want to take up all your time and whatnot.

    Thanks again!

  11. #11
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    No problem, and post back if you get stuck. The goal is to throw you into the pond and let you learn to swim, but not drown you.
    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. form question-auto date?
    By darklite in forum Access
    Replies: 4
    Last Post: 09-02-2010, 09:32 AM
  2. Replies: 1
    Last Post: 07-07-2010, 04:22 PM
  3. set date field on form to date variable
    By laavista in forum Access
    Replies: 3
    Last Post: 06-28-2010, 03:03 AM
  4. Query (Date Question)
    By cillajones in forum Queries
    Replies: 1
    Last Post: 08-09-2008, 12:05 PM
  5. Question about creating a date calculation tool
    By bazillion in forum Programming
    Replies: 0
    Last Post: 01-25-2008, 12:08 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