View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
obsessive obsessive is offline
external usenet poster
 
Posts: 12
Default Conditional BackColor Loop

This did it... thanks for your help...FYI...I prohibited entries with a
variance of 10 through the textbox exit function.. everything
works perfect (so far anyway)

Private Sub ChkEditValues(Variance As Long)


Dim Answer, SampleVal, StandardVal As Long
Dim TextBoxes(5) As String
Dim MyMsg As String
Dim ErrFlag As Boolean


StandardVal = Val(Me.Controls("Standard").Text)

For Ctr = 1 To 5
TextBoxes(Ctr) = Me.Controls("Sample" & CStr(Ctr)).Name
Next


ErrFlag = False
For Ctr = 1 To 5
Set MyTB = Me.Controls(TextBoxes(Ctr))
SampleVal = Val(MyTB.Text)
If SampleVal <= StandardVal - 3 Then MyTB.BackColor = &HFFFF&
If SampleVal = StandardVal + 3 Then MyTB.BackColor = &HFFFF&
If MyTB.BackColor = &HFFFF& Then
ErrFlag = True
End If
Next
If ErrFlag Then
MyMsg = "Please check the highlighted entries. "
MyMsg = MyMsg & "Click YES if OK."
Answer = MsgBox(MyMsg, vbYesNo, "Double Check")
If Answer = vbYes Then
For Ctr = 1 To 5
Set MyTB = Me.Controls(TextBoxes(Ctr))
MyTB.BackColor = &H80000005
Next
Else
ErrFlag = False
Exit Sub
End If
End If
PutData
MsgBox "Edits have been entered"


End Sub