Day function running on following day instead of intended current day

  • Thread starter Thread starter BFish via AccessMonster.com
  • Start date Start date
B

BFish via AccessMonster.com

I have this VBA to run an update query on the 1st of the month;

If day(Date) = 1 Then

CurrentDb.Execute "qupdBusinessCode", dbFailOnError

End If


It will only execute on the next day (the 2nd). Just to check If I had the
right syntax I ran {day(Date) = 1} in the intermediate window and it will
only return true when it's the 1st of the month. If I change the statement
to {day(Date) = 2} then the function will execute on the 3rd day of the month.


I have looked and relooked at my update query (it works fine when manually
running) for any date reference that would cause this to occur, there is no
date reference or even a datefield in it or the totals query it is based off.
I am quite at a lost here on what seems should be a very simple matter. Why
is this executing a day after intended?

Thanks,

Bill Fischer
 
Bill:

I can't offer any cogent explanation for the behaviour, but you could try
explicitly referencing the VBA object library:

If Day(VBA.Date) = 1 then

or use the Now function:

If Day(Now()) = 1 Then

or the Format function:

If Format(VBA.Date,"dd") = "01" Then

Ken Sheridan
Stafford, England
 
Ken,

Thanks for the reply. I used the Day(VBA.Date)=1 which seems to have taken
care of the issue.

Really appreciate your answer as I see I even posted in the wrong subgroup.
The people in this newsqroup are the Greatest.

Bill Fischer


Ken said:
Bill:

I can't offer any cogent explanation for the behaviour, but you could try
explicitly referencing the VBA object library:

If Day(VBA.Date) = 1 then

or use the Now function:

If Day(Now()) = 1 Then

or the Format function:

If Format(VBA.Date,"dd") = "01" Then

Ken Sheridan
Stafford, England
I have this VBA to run an update query on the 1st of the month;
[quoted text clipped - 18 lines]
Bill Fischer
 
Back
Top