By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,215 Members | 1,517 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,215 IT Pros & Developers. It's quick & easy.

Dynamic Field Color Change for whole form?

P: n/a
Hi

I have a form with 20 fields. When I place my form in EDIT mode, I
want all the
fields to have their BackColor set to Yellow. Can this be done without
having
to assign the color to each field individually with multiple
statements?

Thanks Greg

Mar 7 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
<Ap******@gmail.com> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.com...
Hi

I have a form with 20 fields. When I place my form in EDIT mode, I
want all the
fields to have their BackColor set to Yellow. Can this be done without
having
to assign the color to each field individually with multiple
statements?

Thanks Greg

Yes you can, but your code should be able to set them back again as well.
So you could structure it like the sub below so that you will be able to
call either
SetEditMode True
or
SetEditMode True
but you only write one sub:
Private Sub SetEditMode(EditModeOn As Boolean)

On Error GoTo Err_Handler

Dim ctl As Control
Dim lngColor As Long

If EditModeOn Then
lngColor = vbYellow
Else
lngColor = vbWhite
End If

For Each ctl In Me.Controls
If TypeOf ctl Is TextBox Then
ctl.Properties("BackColor").Value = lngColor
End If
Next ctl

Exit_Handler:
Exit Sub

Err_Handler:
MsgBox Err.Description, vbExclamation, "Error No: " & Err.Number
Resume Exit_Handler

End Sub
Mar 7 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.