Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2017
    Posts
    1

    Unanswered: LDOM Last day of month

    Hi all,

    I'm a little out of practice with my MS Access and I wanted to find the last day of the month for an End date I have and so I swiped this off the internet

    Public Function Lastdayofmonth(D As Date) As Date

    *** Dim LDOM As Date
    *** Dim NM As Date

    *** NM = DateAdd("m", 1, D)
    *** LDOM = DateSerial(Year(NM), Month(NM), "1")
    *** LDOM = DateAdd("d", -1, LDOM)

    *** Lastdayofmonth = LDOM

    End Function



    I created another version using this code

    Public Function LastDayInMonth(Optional dtmDate As Variant) As Date
    If IsMissing(dtmDate) Then
    dtmDate = Date
    End If

    LastDayInMonth = DateSerial( _
    Year(dtmDate), Month(dtmDate) + 1, 0)
    End Function


    It worked until I closed down the database and not I get the same error as before, which make me think the problem is around how I've saved the module.

    I'm such a pleb, I named the module the same thing so the query couldn't recognise one from the other what a plonker!


    Can anyone shed any light?

    many thanks in anticipation

    Anthony
    Last edited by Panzerattack; 02-07-17 at 14:52. Reason: Solved

  2. #2
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,476
    Provided Answers: 11
    OPen the Database

    Alt+f11 in vb

    Then Click Tools -> Reference and your see whats missing that be the problem.
    hope this help

    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.
    DONT WORRY ABOUT THOSE WHO TALK BEHIND YOUR BACK
    THEY'RE BEHIND YOU FOR A REASON

Posting Permissions

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