[AccessD] Question on preferred coding

Bob Gajewski rbgajewski at roadrunner.com
Tue Jan 20 22:28:33 CST 2009


Hi Folks
 
I have a subform with 100+ fields. I want to change the backcolor of each
field based upon the value entered by the user, after validation.
 
Both of the examples below seem to work fine. Is there a preferred way, or
is one better than the other?
 
Thanks
Bob Gajewski
 
Sample #1
  _____  

Private Sub EventSeatA001_BeforeUpdate(Cancel As Integer)
    If Me.ActiveControl <> "A" And Me.ActiveControl <> "R" And
Me.ActiveControl <> "C" And Me.ActiveControl <> "P" And Me.ActiveControl <>
"S" And Me.ActiveControl <> "N" Then
        MsgBox "The valid choices are 'A' (available), 'R' (reserved), 'C'
(chorus/cast), 'P' (pre-sale), 'S' (sold), and 'N' (not available)."
        Cancel = True
        Me.ActiveControl.Undo
    End If
End Sub

  _____  

Private Sub EventSeatA001_AfterUpdate()
SetSeatBackColor
End Sub

  _____  

 
Sample #2
  _____  

Private Sub EventSeatA001_BeforeUpdate(Cancel As Integer)
    If Me.ActiveControl <> "A" And Me.ActiveControl <> "R" And
Me.ActiveControl <> "C" And Me.ActiveControl <> "P" And Me.ActiveControl <>
"S" And Me.ActiveControl <> "N" Then
        MsgBox "The valid choices are 'A' (available), 'R' (reserved), 'C'
(chorus/cast), 'P' (pre-sale), 'S' (sold), and 'N' (not available)."
        Cancel = True
        Me.ActiveControl.Undo
    Else
        SetSeatBackColor
    End If
End Sub

  _____  

  _____  

 
P Please consider the environment before printing this e-mail 
 



More information about the AccessD mailing list