Link to home
Start Free TrialLog in
Avatar of woodje
woodjeFlag for United States of America

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.
Dim intMonth As Integer
intMonth = Month(Now)
.Form.lblcurrent.Caption = MonthName(Month(DateSerial(Year(Now), intMonth + 1, Day(Now))))

Open in new window

Avatar of Malik1947
Malik1947

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)
use this code instead.



Dim intMonth As Integer
intMonth = Month(Now)
.Form.lblcurrent.Caption = MonthName(Month(Now) + 1)

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Limbeck
Limbeck

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of woodje

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.