There must be a better way to ...

J

johnb

Hi All
I have a Form and Subform with 40 something Combo, Text and Memo controls.
Users populate the form and print it. Great! all works well....er no. The
user decides to change a few controls values here and there and then want the
changes highlighted on screen and on the printed report. So I insert this
code on the form

Private Sub FrameFinish_AfterUpdate()
If Me.FrameFinish.Value <> Me.FrameFinish.OldValue Then
With Me.FrameFinish
.FontWeight = 700
.ForeColor = vbRed
.Tag = "T"
End With
End If
End Sub

And Screen formatting is sorted I then insert the following code in the
Report and the report formatting is sorted

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

If Forms!frm_CPS_Details_mgt.Form!SubForm1!FrameFinish.Tag = "T" Then
With Me.FrameFinish
.FontWeight = 700
.FontSize = 12
.ForeColor = RGB(255, 0, 0)
End With
Else
With Me.FrameFinish
.FontWeight = 400
.ForeSize = 10
.ForeColor = RGB(0, 0, 0)
End With
End If
End Sub

But with 40 + controls setting this up and maintenance is going to be a real
bummer.

There must be a better way!! Help!

johnb
 
M

Maurice

You could loop through the controls to do the checking and based on that
change the visual state.

Dim ctl as control

for each ctl in me.controls
if ctl.value <> ctl.oldvalue then
.FontWeight = 700
.ForeColor = vbRed
.Tag = "T"
end if
next


In the report you can check the Tag of the control to set the various
properties like:

Dim ctl as control

For each ctl in me.controls
if ctl.tag="T" then
.FontWeight = 700
.FontSize = 12
.ForeColor = RGB(255, 0, 0)
else
'-> alternative code here...
end if
next

hth
 
L

Linq Adams via AccessMonster.com

I believe you'll also need to qualify the type of controls you're looping
thru. Checking to see if

ctl.value <> ctl.oldvalue

on a control that doesn't have a Value /OldValue property, such as a label,
will throw an error if I remember correctly.
 
J

johnb

Hi Maurice and Linq

Thanks for the comments. I shall now try and implement them. Speak to you
soon.

johnb
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top