Backwards/Forwards by last date of the month problem!

VegaLA

Registered User.
Local time
Today, 15:01
Joined
Jul 12, 2006
Messages
101
Good day all,
I hope everyone enjoyed the Christmas break as much as I did and
you have my sympathy if you reply to this question today since it may mean that like me you are back to the office already !

Anyway, I do have a problem regardign the DateSerial function. I have a control on a form named txtLMonth which uses Dateserial to show the last day of the previous month like so....

Me.txtLMonth = DateSerial(Year(Date), Month(Date), 0)

Which works perfectly however i've left the field open so that the user can go back or forwards a month.
The code below works great for goign forwards a month,

Me.txtLMonth = DateSerial(Year(txtLMonth), Month(txtLMonth) + 2, 0)

it displays the last date of that month, however the back button seems to go back not one but two months. The code for which is below,

Me.txtLMonth = DateSerial(Year(txtLMonth), Month(txtLMonth) - 1, 0)

I cannot for the life of me figure out why it is doing that but if anyone can advise me on correcting this i'd be very gratefull.

Mitch....
 
Me.txtLMonth = DateSerial(Year(txtLMonth), Month(txtLMonth) - 1, 0)

needs to be

Me.txtLMonth = DateSerial(Year(txtLMonth), Month(txtLMonth), 0)
 
Me.txtLMonth = DateSerial(Year(txtLMonth), Month(txtLMonth) - 1, 0)

needs to be

Me.txtLMonth = DateSerial(Year(txtLMonth), Month(txtLMonth), 0)


Thank you, that did the job perfectly.
Have a GREAT New year !!

Mitch....
 

Users who are viewing this thread

Back
Top Bottom