Sam Summers
Registered User.
- Local time
- Today, 16:11
- Joined
- Sep 17, 2001
- Messages
- 939
Hi,
Being self taught i do not fully understand all vba functions and procedures and which best to use yet.
I have this code:
Now it is working but only to a point.
So the first form (Position1) is Blank and this works.
And Position2 is "Foam" and this code works and shows the correct colour but everything (code) after this is not working so i am doing something wrong?
Any pointers would be great.
Many thanks in advance
Being self taught i do not fully understand all vba functions and procedures and which best to use yet.
I have this code:
Code:
Private Sub Form_Current()
Me!Position1QrySubform.Form!Type.SetFocus
If Me!Position1QrySubform.Form!Type = "Foam" Then
Me.Btn1.BackColor = RGB(255, 228, 181)
Else
If Me!Position1QrySubform.Form!Type = "Water" Then
Me.Btn1.BackColor = RGB(255, 0, 0)
Else
If Me!Position1QrySubform.Form!Type = "Powder" Then
Me.Btn1.BackColor = RGB(30, 144, 255)
Else
If Me!Position1QrySubform.Form!Type = "CO2" Then
Me.Btn1.BackColor = RGB(0, 0, 0)
Else
If Me!Position1QrySubform.Form!Type = "Wet Chemical" Then
Me.Btn1.BackColor = RGB(0, 201, 87)
Else
Me!Position2QrySubform.Form!Type.SetFocus
If Me!Position2QrySubform.Form!Type = "Foam" Then
Me.Btn2.BackColor = RGB(255, 228, 181)
Else
If Me!Position2QrySubform.Form!Type = "Water" Then
Me.Btn2.BackColor = RGB(255, 0, 0)
Else
If Me!Position2QrySubform.Form!Type = "Powder" Then
Me.Btn2.BackColor = RGB(30, 144, 255)
Else
If Me!Position2QrySubform.Form!Type = "CO2" Then
Me.Btn2.BackColor = RGB(0, 0, 0)
Else
If Me!Position2QrySubform.Form!Type = "Wet Chemical" Then
Me.Btn2.BackColor = RGB(0, 201, 87)
Else
Me!Position3QrySubform.Form!Type.SetFocus
If Me!Position3QrySubform.Form!Type = "Foam" Then
Me.Btn3.BackColor = RGB(255, 228, 181)
Else
If Me!Position3QrySubform.Form!Type = "Water" Then
Me.Btn3.BackColor = RGB(255, 0, 0)
Else
If Me!Position3QrySubform.Form!Type = "Powder" Then
Me.Btn3.BackColor = RGB(30, 144, 255)
Else
If Me!Position3QrySubform.Form!Type = "CO2" Then
Me.Btn3.BackColor = RGB(0, 0, 0)
Else
If Me!Position3QrySubform.Form!Type = "Wet Chemical" Then
Me.Btn3.BackColor = RGB(0, 201, 87)
Else
Me!Position4QrySubform.Form!Type.SetFocus
If Me!Position4QrySubform.Form!Type = "Foam" Then
Me.Btn4.BackColor = RGB(255, 228, 181)
Else
If Me!Position4QrySubform.Form!Type = "Water" Then
Me.Btn4.BackColor = RGB(255, 0, 0)
Else
If Me!Position4QrySubform.Form!Type = "Powder" Then
Me.Btn4.BackColor = RGB(30, 144, 255)
Else
If Me!Position4QrySubform.Form!Type = "CO2" Then
Me.Btn4.BackColor = RGB(0, 0, 0)
Else
If Me!Position4QrySubform.Form!Type = "Wet Chemical" Then
Me.Btn4.BackColor = RGB(0, 201, 87)
Else
Me!Position5QrySubform.Form!Type.SetFocus
If Me!Position5QrySubform.Form!Type = "Foam" Then
Me.Btn5.BackColor = RGB(255, 228, 181)
Else
If Me!Position5QrySubform.Form!Type = "Water" Then
Me.Btn5.BackColor = RGB(255, 0, 0)
Else
If Me!Position5QrySubform.Form!Type = "Powder" Then
Me.Btn5.BackColor = RGB(30, 144, 255)
Else
If Me!Position5QrySubform.Form!Type = "CO2" Then
Me.Btn5.BackColor = RGB(0, 0, 0)
Else
If Me!Position5QrySubform.Form!Type = "Wet Chemical" Then
Me.Btn5.BackColor = RGB(0, 201, 87)
Else
Me!Position6QrySubform.Form!Type.SetFocus
If Me!Position6QrySubform.Form!Type = "Foam" Then
Me.Btn6.BackColor = RGB(255, 228, 181)
Else
If Me!Position6QrySubform.Form!Type = "Water" Then
Me.Btn6.BackColor = RGB(255, 0, 0)
Else
If Me!Position6QrySubform.Form!Type = "Powder" Then
Me.Btn6.BackColor = RGB(30, 144, 255)
Else
If Me!Position6QrySubform.Form!Type = "CO2" Then
Me.Btn6.BackColor = RGB(0, 0, 0)
Else
If Me!Position6QrySubform.Form!Type = "Wet Chemical" Then
Me.Btn6.BackColor = RGB(0, 201, 87)
Else
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End Sub
Now it is working but only to a point.
So the first form (Position1) is Blank and this works.
And Position2 is "Foam" and this code works and shows the correct colour but everything (code) after this is not working so i am doing something wrong?
Any pointers would be great.
Many thanks in advance