Problem with Continuous Form

  • Thread starter Thread starter Scott A
  • Start date Start date
S

Scott A

I have some code which toggles two labels on and off based
on the date values on a continuous form using the FormLoad
event.

When the first record displayed in the continuous form
meets one of the conditions described in the procedure, it
displays the label on all of the following records whether
they meet the criteria or not. I didn't expect this and
am wondering how I should modify the code.

Here is the code...
===========================================================
Private Sub Form_Load()

If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "All equipment purchased in the last 30
days has been delivered."
End If

Dim DatToday As Date
Dim ForseenDeliveryDate As Date
DatToday = Date

'Toggles Overdue label on and off
If Me![ForseenDeliveryDate] < DatToday Then
Me!txtOverdue.Visible = True
Else
Me!txtOverdue.Visible = False
End If


'Toggles Today label on and off
If Me![ForseenDeliveryDate] = DatToday Then
Me!txtToday.Visible = True
Else
Me!txtToday.Visible = False
End If

End Sub
==========================================================
Any thoughts?

Thanks,

Scott
 
Scott A said:
I have some code which toggles two labels on and off based
on the date values on a continuous form using the FormLoad
event.

When the first record displayed in the continuous form
meets one of the conditions described in the procedure, it
displays the label on all of the following records whether
they meet the criteria or not. I didn't expect this and
am wondering how I should modify the code.
[code snipped]

You have to consider continuous forms formatting issues while looking at
the form in design view. While in design view it is obvious that you have
only one copy of each of these labels. Each label object has properties
for Visible, BackColor, etc.. You do not see multiple rows of controls
while in design view because *there really is only one set of controls*.
When you are in continuous view Access is merely making copies of this one
set of controls. That is why when you change an object's properties it
affects all rows, because it is in fact the same label object in every row.
Only data will be different per row.

In Access 2000 and later they added Conditional Formatting to allow for
some "per-row" formatting of the form's objects. This is somewhat limited
though and I believe that the Visible property is not one of the properties
that can be toggled using CF. You could still look at the features in CF
to see if something that is available would work for you.
 
Back
Top