format report

  • Thread starter Thread starter Joel
  • Start date Start date
J

Joel

Hello,

I'm trying to make a line appear in a report when the EndDate is equal to
today's date. It is giving me an error.

Option Compare Database

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Now() = EndDate Then
Me.Line126.Properties = Visible
End If
End Sub


I'm sure I have "Me.Line126.Properties = Visible" formated wrong or
something?

Thank you for your help,
Joel
 
Hello,

I'm trying to make a line appear in a report when the EndDate is equal to
today's date. It is giving me an error.

Option Compare Database

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Now() = EndDate Then
Me.Line126.Properties = Visible
End If
End Sub

I'm sure I have "Me.Line126.Properties = Visible" formated wrong or
something?

Thank you for your help,
Joel

Several comments.

1) You would use
Me.Line126.Visible = True ' (or False)

2 Once the criteria was met, the line would then become visible for
all other records, even if the criteria on those other records was not
met. You must code to turn the visiblity Off if the criteria is not
met.

3) Your line will never show because your criteria
If Now() = EndDate
will never be true UNLESS the [EndDate] value was EXACTLY the date AND
time you ran this report, i.e. 2/28/2005 9:52 AM.

Now() contains a Time as well as a Date value.
Date() contains just a Date Value. Use Date, unless you need the time
value.

4) In VBA you do not use the () after Now or Date.

Try it this way:
If [EndDate] = Date Then
Me.Line126.Visible = True
Else
Me!Line126.Visible = False
End If

Hope this is clear.
 
Fred - Thank you so much. That worked perfectly!

fredg said:
Hello,

I'm trying to make a line appear in a report when the EndDate is equal to
today's date. It is giving me an error.

Option Compare Database

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Now() = EndDate Then
Me.Line126.Properties = Visible
End If
End Sub

I'm sure I have "Me.Line126.Properties = Visible" formated wrong or
something?

Thank you for your help,
Joel

Several comments.

1) You would use
Me.Line126.Visible = True ' (or False)

2 Once the criteria was met, the line would then become visible for
all other records, even if the criteria on those other records was not
met. You must code to turn the visiblity Off if the criteria is not
met.

3) Your line will never show because your criteria
If Now() = EndDate
will never be true UNLESS the [EndDate] value was EXACTLY the date AND
time you ran this report, i.e. 2/28/2005 9:52 AM.

Now() contains a Time as well as a Date value.
Date() contains just a Date Value. Use Date, unless you need the time
value.

4) In VBA you do not use the () after Now or Date.

Try it this way:
If [EndDate] = Date Then
Me.Line126.Visible = True
Else
Me!Line126.Visible = False
End If

Hope this is clear.
 
Back
Top