I have been trying to write vba for conditionals but I got down three groupings and then it gets a Run-Time error '2465' which cant find the field but it worked before adding the third grouping. The code looks like:
If [PhaseImbal] < 2 Then [AmpsKwAApr].BackColor = vbYellow
If [PhaseImbal] > 2 Then [AmpsKWAApr].BackColor = vbRed
If [PhaseImbal] = 8 Then [AmpsKWAApr].BackColor= vbWhite
Then that is repeated 3 times with different AmpsKWAAPr's. The first 2 times it worked then the third it received that error. I was wondering how I can get it to recognize the field again and having three Then statements so I can only have 3 rows instead of 9. Any suggestions will be greatly appreciated!
**changed up- now my question is:
Ive actually changed it up completely, but I have another question. I finally just used a text box to obtain a value that i was getting that error from, AmpacityRefence. I am wanting to divide AmpacityReference by AmpsA and do conditions from there but I am not getting the correct values from the divisions I dont think. Here is my code I have:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim AmpacA As Double
Dim AmpacB As Double
Dim AmpacC As Double
AmpacA = Me![AmpacityReference] / [AmpsA]
AmpacB = Me![AmpacityReference] / [AmpsB]
AmpacC = Me![AmpacityReference] / [AmpsC]
If AmpacA > 0.6699 And AmpacA < 0.90001 Then
AmpsKWAL.BackColor = vbYellow
ElseIf AmpacA > 0.9 Then
AmpsKWAL.BackColor = vbRed
ElseIf AmpacA < 0.67 Then
AmpsKWAL.BackColor = vbWhite
End If
End Sub
The AmpacB and AmpacC will just be used in replicated if elseif statements. Somethings going wrong with my division but I dont know how. All suggestions will help greatly!