woodje
asked on
Problem with VBA code to set label value
Hello,
I am using the below code to render the caption of a label. This has worked for most of the month but today it decided to not work. Up until to day this label has read "Febuary". Now today it is reading "March". I can not figure out why this is happening. Can you please help me with this. This currently in production and it is causing confusion for my people entering data.
I am using the below code to render the caption of a label. This has worked for most of the month but today it decided to not work. Up until to day this label has read "Febuary". Now today it is reading "March". I can not figure out why this is happening. Can you please help me with this. This currently in production and it is causing confusion for my people entering data.
Dim intMonth As Integer
intMonth = Month(Now)
.Form.lblcurrent.Caption = MonthName(Month(DateSerial(Year(Now), intMonth + 1, Day(Now))))
are there any other parts of your code that change the label caption?
hm you are checking febr. 30th ;)
try using 1 instead of day(now)
try using 1 instead of day(now)
use this code instead.
Dim intMonth As Integer
intMonth = Month(Now)
.Form.lblcurrent.Caption = MonthName(Month(Now) + 1)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That worked great and thanks for seeing the end of the year issue that was rough for last year.
glad to be of help :)
Ed.
Ed.