Results 1 to 7 of 7
  1. #1
    azhar2006's Avatar
    azhar2006 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2012
    Posts
    528

    function


    Hello all
    What is the function that gives me a warning before 6 months of the effective date of merchandise

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,535
    Access and VBA make a number of date functions available. It sounds as though you will need to use DateDiff() or DateAdd() but a bit more info would enable us to help you more.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    azhar2006's Avatar
    azhar2006 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2012
    Posts
    528
    Thank you very much Bob Fitzpatrick
    Inquiry
    Expiration date medicine

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    Build a query for form or report. Try:

    SELECT * FROM tablename WHERE Date() = DateAdd("m",-6,[date field]);
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    azhar2006,

    What June has offered is called SQL. You can use this code as a RecordSource to a form. You can paste the code into the form's Record Source property field. While you are in Design View for your form, the Record Source field is found in the Property Sheet. The property field is loacted within the "Data" tab.

    You need to place the name of your table and the name of the date field where it is indicated by the color red.

    SELECT * FROM tablename WHERE Date() = DateAdd("m",-6,[date field]);

    This will show all the records where the date field is equal to the current month minus 6 months.

  6. #6
    azhar2006's Avatar
    azhar2006 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2012
    Posts
    528
    Thank you very much BOB
    Thank you very much JUNE
    Thank you very much ITSME
    It did not work with me
    But I found an example in the forum to friend (JUNE7)
    Between Date() And DateAdd("m",6,Date())
    And it worked fine

  7. #7
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Good work. There is more than one way to go about achieving your desired results. You can apply criteria in the "Access Query Builder" window. When you build a query, there are fields available to apply your criteria. You could use code like this example in the criteria field of a query object.

    Code:
    Date() = DateAdd("m",-6,[date field]);
    There is an option in the query builder to change the view. You can view the SQL of your query object by selecting "SQL View" in the upper left hand corner. You can paste code like this example into "SQL View".


    Code:
    [SELECT *, [date field] FROM tablename WHERE Date() = DateAdd("m",-6,[date field]);
    As you discovered, if you want to see a range of dates in your results, you will need to use the "Between" operator.

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

Similar Threads

  1. Between function
    By brownk in forum Queries
    Replies: 2
    Last Post: 09-10-2012, 08:33 AM
  2. Can't run a function?
    By Kemo in forum Programming
    Replies: 4
    Last Post: 05-20-2012, 09:25 AM
  3. Using the IIf Function?
    By djclntn in forum Queries
    Replies: 14
    Last Post: 03-19-2012, 03:50 PM
  4. Max function???
    By kaite07 in forum Queries
    Replies: 1
    Last Post: 11-10-2010, 05:20 PM
  5. Want function to get current function name
    By Davis DeBard in forum Programming
    Replies: 2
    Last Post: 08-13-2009, 05:02 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