Results 1 to 10 of 10
  1. #1
    Gina Maylone is offline Always learning
    Windows 7 64bit Access 2013
    Join Date
    Jun 2013
    Location
    Afton, MN
    Posts
    544

    Unbound date field giving me fits!

    Hello all,



    I have an unbound form that I use for processing loan payments. I have an unbound "datepaid" field, formatted as Short Date. I have a button to process the various types of payments (full, short, etc) and...
    Code:
     
    If vamountpaid > 0 And Format (datepaid, "short date") <= DueDate And amountpaid > 0 And PaidDate <> Null Then
    In debug mode, no matter what I do, (on hover) the datepaid shows 12:00:00 AM, on debug.print its 12/30/1899. I've used the calendar control, NOT used the calendar control, etc. Obviously, my if statement does not process.

    What is going on here? TIA!!

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    12/30/1899 12:00:00 AM is the start of all dates numerically. Usu when its blank it will convert to this (but not null)
    which will always be < duedate

  3. #3
    Gina Maylone is offline Always learning
    Windows 7 64bit Access 2013
    Join Date
    Jun 2013
    Location
    Afton, MN
    Posts
    544
    Thank you ranman256, but it is not blank. There will always be a date in there.

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    You have fields PaidDate and DatePaid----is this correct or a typo?

    This Format (datepaid, "short date") <= DueDate
    is comparing a text value to a date/time datatype (if DueDate is a Date/time datatype)

  5. #5
    Gina Maylone is offline Always learning
    Windows 7 64bit Access 2013
    Join Date
    Jun 2013
    Location
    Afton, MN
    Posts
    544
    Hi Orange,

    DatePaid is the unbound field on my form, paiddate is the actual paid date in the table.

    Thanks for the info!

  6. #6
    Gina Maylone is offline Always learning
    Windows 7 64bit Access 2013
    Join Date
    Jun 2013
    Location
    Afton, MN
    Posts
    544
    Ok, so I've tried using the conjetdate like this:
    Code:
    datepaid = Format(datepaid, conJetDate)
    and
    Code:
    If vamountpaid > 0 And Format([Forms]![NewPaymentForm]!datepaid, conJetDate) <= DueDate And amountpaid > 0 And PaidDate <> Null Then
    and I'm getting a type mismatch, because the datepaid is still 12:00:00 AM in the code window. How do I just get that unbound field formatted as a date??

    Again, thanks all!

  7. #7
    hapm is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    197
    fyi
    Code:
    PaidDate <> Null
    This expression will never be True, but will always evaluate to Null. The same goes for Anything And Null, so your if will never evaluate to True at all. Do some tests in the direct window with the following expressions:
    Code:
    ?True <> Null
    ?1 <> Null
    ?"A String"<>Null
    ?True And Null
    ?Null = Null
    It's a common mistake. The solution is to use
    Code:
    Not IsNull(PaidDate)
    PS: the following evaluates to True:
    Code:
    True Or Null

  8. #8
    hapm is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    197
    For the problem in the op, as ranman256 stated:
    Quote Originally Posted by ranman256 View Post
    12/30/1899 12:00:00 AM is the start of all dates numerically. Usu when its blank it will convert to this (but not null)
    which will always be < duedate
    This doesn't directly mean that the field on the form is blank. Another reason would be that you misspelled the controlname or the control isn't directly accessible from the context of your code (only possible from inside the controls form module, or explicitly by having a reference to the form object). To avoid errors like that use datepaid.Value instead of datepaid or use Option Explicit at the top of your code modules (best practice anyway).

  9. #9
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Have you tried removing the Format function from datePaid?
    Can you post a copy of your database---just enough data to show the problem?
    Zip format.

  10. #10
    Gina Maylone is offline Always learning
    Windows 7 64bit Access 2013
    Join Date
    Jun 2013
    Location
    Afton, MN
    Posts
    544
    Thank you all for your help! I changed PaidDate<>Null to not isnull([paiddate]), and removed the format function. And all is well now! I have another question that I am posting in a new thread. Again, THANK YOU ALL!!

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

Similar Threads

  1. Replies: 5
    Last Post: 01-30-2015, 02:45 PM
  2. date/time field giving me issues
    By bchi99 in forum Queries
    Replies: 1
    Last Post: 11-04-2014, 04:51 PM
  3. Replies: 3
    Last Post: 07-13-2012, 09:18 AM
  4. Replies: 5
    Last Post: 06-22-2011, 08:47 PM
  5. one form fits all rights
    By sugar in forum Programming
    Replies: 4
    Last Post: 06-30-2009, 09:12 AM

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