Date() function in VB Code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a report that based on the current month I want the field "Day30" to
be visible or not so I tried the following code:

If (Month(Date())) = 11 Then
[Day30] = not visible
Else [Day30] = visible

I did this simple so I could see if it works but it defaults (Month(Date()))
to
(Month(Date)) and then I get a compiling error.

How do I get it to look at the current date/month to be able to compare my
criteria against?

Any help would be greatly appreciated!!

Thanks.
 
Try this line in the On Format event of the section containing the control
Me.Day30.Visible = (Month(Date) <>11)
 
Worked like a charm but how do I additional criteria i.e. other months?
Thanks!

Duane Hookom said:
Try this line in the On Format event of the section containing the control
Me.Day30.Visible = (Month(Date) <>11)

--
Duane Hookom
MS Access MVP
--

SMac said:
I have a report that based on the current month I want the field "Day30" to
be visible or not so I tried the following code:

If (Month(Date())) = 11 Then
[Day30] = not visible
Else [Day30] = visible

I did this simple so I could see if it works but it defaults
(Month(Date()))
to
(Month(Date)) and then I get a compiling error.

How do I get it to look at the current date/month to be able to compare my
criteria against?

Any help would be greatly appreciated!!

Thanks.
 
Excuse me for butting in, but I just couldn't resist.

If you'll explain the rule you are using, I'm sure someone can come up with
some code. For instance, the rule might be show Day30 if the month has 31
days. That could be done with something like:

Me.Day30.Visible = DateSerial(Year(Date()),Month(Date())+1,0) = 31

SMac said:
Worked like a charm but how do I additional criteria i.e. other months?
Thanks!

Duane Hookom said:
Try this line in the On Format event of the section containing the
control
Me.Day30.Visible = (Month(Date) <>11)

--
Duane Hookom
MS Access MVP
--

SMac said:
I have a report that based on the current month I want the field "Day30"
to
be visible or not so I tried the following code:

If (Month(Date())) = 11 Then
[Day30] = not visible
Else [Day30] = visible

I did this simple so I could see if it works but it defaults
(Month(Date()))
to
(Month(Date)) and then I get a compiling error.

How do I get it to look at the current date/month to be able to compare
my
criteria against?

Any help would be greatly appreciated!!

Thanks.
 
Back
Top