CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: MS Access Macro

  1. #1
    Join Date
    May 2001
    Posts
    18

    MS Access Macro

    Please help. I have a database which has a report. The report has a query which needs to check that a field contains a date in a certain format. The date is written as the year, month, and day put together into one string. For example today would be written as 20010730. How can I use MS Access to get the values that are greater than the current date. Or even more simply how can I get the values of the current month, day, and year. I know this is a lot to ask for but any help would be appreciated.

    Thanks in advance,
    Calvin



  2. #2
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: MS Access Macro

    Since you always user 8 digits for the date, you might as wel evaluate it as a number, and you then sort it. Let's write it down:

    2001/07/01 -> 20010731
    is later (bigger) than
    2001/06/28 -> 20010628



    Also, to get a specific part of a date, you can use the DatePart function.

    DatePart("d","2001/06/28") ' would give 28
    DatePart("m","2001/06/28") ' would give 6
    DatePart("yyyy","2001/06/28") ' would give 2001




    Tom Cannaerts
    [email protected]

    Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

  3. #3
    Join Date
    May 2001
    Posts
    18

    Re: MS Access Macro

    I can't get the MS Access Query Builder to use any code to query one column to be greater than the current date. Like I could just write in the criteria row:
    >20010730 and that works but I wanted to get this to happen automatically. I thought I would be able to figure it out but had no luck.
    Thanks again.


Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured