Results 1 to 5 of 5
  1. #1
    ynotaz is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2014
    Posts
    9

    Question Help on a simple statement

    I've been using access for a while but in a very passive environment. My first post is a question, I need some help on this.

    Why doesn't this statement compare correctly?

    If Rst.Fields("DuesPaidYear") >= Val(Format(Now(), "YY")) Then
    GoTo Checktime
    End If

    The table column is a numeric 2 digit field. When the table field is 10 and the year is 14 it does not show as low.



    Thanks for any help.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Why are you using .Fields and why are you using the val function?

    Just compare the field value for the current record to a variable or constant.

    If Rst![DuesPaidYear] >= 14 Then

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    In addition to ItsMe comment, you could investigate using a DateTime data type for Dates.

    Also there is Year function to get the Year from today's date Today's date is Date in Access

    currentYear = Year(Date) , similarly for month CurrentMonth = Month(Date)

  4. #4
    ynotaz is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2014
    Posts
    9
    I did make the changes to use "date", "year", and "Month" in the routine and it works....

    THANKS for the help it is much more straightforward.....

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    Happy to help. Good luck with your project.

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

Similar Threads

  1. simple delete SQL statement not working
    By markjkubicki in forum Programming
    Replies: 9
    Last Post: 05-22-2013, 05:49 PM
  2. Replies: 2
    Last Post: 02-22-2012, 07:14 AM
  3. Simple SQL statement in VB
    By JFo in forum Programming
    Replies: 5
    Last Post: 10-05-2011, 09:55 PM
  4. Replies: 1
    Last Post: 07-30-2011, 07:58 AM
  5. is this a valid SQL statement ? (simple)
    By markjkubicki in forum Queries
    Replies: 1
    Last Post: 07-22-2010, 06:49 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