Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

endofMonth function

Status
Not open for further replies.

tziviak

Technical User
Oct 10, 2002
128
US
Is there a function (as in excel) to check if a certain date is the last day of the month?
thank you
 
Hi tziviak,

There are several ways to do it both in Excel and Access. Don't know exactly what you are referring to but both have the DateSerial function which will give the date of the last of the month ..

Code:
DateSerial(
Code:
Year
Code:
,
Code:
Month+1
Code:
, 0)

.. which you can then compare to your date.

Enjoy,
Tony
 
I'm actually working in access and I have 12 textboxes with dates-and I want to check each box-that if the previous box was the last day of the month-then I should leave that box empty. so how would I go about doing that?
thank you
 
Hi tziviak,

Assuming you know you have a valid date (or nothing) in textbox1 then in the beforeupdate event of textbox2 you could put something like ..

Code:
if Month(Nz(Textbox1)) = Month(Nz(Textbox1) + 1) Then
    If Not IsNull(Textbox2) Then
        Msgbox "Input  not allowed, Textbox1 is End of Month"
        Cancel = True
    end if
End if

Enjoy,
Tony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top