Results 1 to 5 of 5
  1. #1
    dgutsche is offline Advanced Beginner
    Windows 8 Access 2010 64bit
    Join Date
    Aug 2014
    Posts
    35

    Question Simple Query to Retrieve a Date for a Formula

    Hi there

    I have a problem that I need to wrap my head around to make some of my forms work. I have a form (see first picture below) that the user will enter the values for [Cylinder No.] and [Date Broken] into.

    Click image for larger version. 

Name:	Query Question2.png 
Views:	5 
Size:	8.1 KB 
ID:	18049



    The field [Age] is to be calculated using the difference between the [Date Broken] and a value I want to have returned by a simple query. That query should take the value [Cylinder No.] which corresponds to the [CylinderName] field in a table called [Cylinders]. It should return the [Date Made] value for that unique cylinder to the query which is then passed into my formula for the field [Age], the formula being:

    =DateDiff([d],[Date Retrieval]![Date Made],[Date Broken])

    When I created the query I obviously am not passing the [Cylinder No.] value in correctly so I am unsure what I was supposed to put into the criteria field for this to work. If anyone can explain what I am doing wrong that would be great as I have to repeat a similar query on a few forms.

    Click image for larger version. 

Name:	Query Question.png 
Views:	5 
Size:	8.8 KB 
ID:	18048
    Last edited by dgutsche; 09-08-2014 at 11:55 AM. Reason: Solved

  2. #2
    burrina's Avatar
    burrina is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    If your asking it to prompt you, then put it [CylinderName] under criteria. Unclear really of your question. You said CylinderName is really CylinderNo and needs a value.
    Is it okay for CylinderName to be null? Why is Age missing from your criteria?
    Please explain further.

  3. #3
    dgutsche is offline Advanced Beginner
    Windows 8 Access 2010 64bit
    Join Date
    Aug 2014
    Posts
    35
    Thanks Dave!

    So in this case I don't want a prompt for the [Cylinder Name] I want instead for it to use the user supplied value in the field [Cylinder No.] in the form. Since I want the query to be based on that value (it's unique and I want it to use it to find the correct date in the other table) I don't think I can let it stay null. [Age] is not part of my criteria because the purpose of the query is to return the date so an age can be calculated.

    Dustin

  4. #4
    burrina's Avatar
    burrina is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    Aah, Okay! Then use something like this for your criteria.

    [Forms]![YourFormNameHere]![CylinderNo]
    HTH

  5. #5
    dgutsche is offline Advanced Beginner
    Windows 8 Access 2010 64bit
    Join Date
    Aug 2014
    Posts
    35
    Alright once I get back on track I think this will help. That naming format strikes me as somewhat familiar to something I did last I touched this database a couple weeks ago.

    Thanks again!

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

Similar Threads

  1. Replies: 2
    Last Post: 07-17-2014, 01:46 AM
  2. Replies: 21
    Last Post: 06-27-2014, 07:33 AM
  3. Replies: 3
    Last Post: 08-18-2012, 03:25 AM
  4. Use DLookup to Retrieve Field Value from a Date?
    By Heatshiver in forum Programming
    Replies: 8
    Last Post: 04-06-2012, 10:09 AM
  5. Formula cannot retrieve value from Combobox
    By frksdf in forum Programming
    Replies: 7
    Last Post: 01-31-2012, 01:34 PM

Tags for this Thread

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