Hi, I put this under the wring topic thing before so I will put it here.
I have 10 text boxes and instead of writing the same code for each one 10 times, I wondered if i can run the same code on each one with a for statement. Each textbox has the same code run on it.
The code currently is:
DoCmd.GoToRecord , , acGoTo, 1
If Me.textbox1.Value = "Ordering" Then
Me.label1.BackColor = vbGreen
Else
Me.label1.BackColor = vbBlue
End If
and this is repeated for textbox2 and 3 up to 10. However it just changes the numbers 1 to a 2 or 3 etc. I was thinking of something like:
for number = 1 to 10
DoCmd.GoToRecord , , acGoTo, number
If Me.textbox(number).Value = "Ordering" Then
Me.label(number).BackColor = vbGreen
Else
Me.label(number).BackColor = vbBlue
End If
but this doesent work, I think its me.label(number) part.
Any Ideas?
all the textboxes have the same name of textbox, followed by a number 1 to 10. e.g. textbox1,textbox2,textbox3,textbox4 etc
I have 10 text boxes and instead of writing the same code for each one 10 times, I wondered if i can run the same code on each one with a for statement. Each textbox has the same code run on it.
The code currently is:
DoCmd.GoToRecord , , acGoTo, 1
If Me.textbox1.Value = "Ordering" Then
Me.label1.BackColor = vbGreen
Else
Me.label1.BackColor = vbBlue
End If
and this is repeated for textbox2 and 3 up to 10. However it just changes the numbers 1 to a 2 or 3 etc. I was thinking of something like:
for number = 1 to 10
DoCmd.GoToRecord , , acGoTo, number
If Me.textbox(number).Value = "Ordering" Then
Me.label(number).BackColor = vbGreen
Else
Me.label(number).BackColor = vbBlue
End If
but this doesent work, I think its me.label(number) part.
Any Ideas?
all the textboxes have the same name of textbox, followed by a number 1 to 10. e.g. textbox1,textbox2,textbox3,textbox4 etc