<SOLVED>Change a string to be able to use as a text box to access the properties
Right i have been racking my brain on this im sure its something simple but im not getting it. on a form i have 14 text boxes named txtbay1 - 14. Now what i want the code to use the value in that Textbox to find a record and see if a specific value is True/false. Then change the color of the text box depending on value. the tricky thing is i want it to flow through all 14 text boxes doing this check.
this is what i have, i hope you can understand what im trying to do any help would be amazing
thanks in advance
Right i have been racking my brain on this im sure its something simple but im not getting it. on a form i have 14 text boxes named txtbay1 - 14. Now what i want the code to use the value in that Textbox to find a record and see if a specific value is True/false. Then change the color of the text box depending on value. the tricky thing is i want it to flow through all 14 text boxes doing this check.
this is what i have, i hope you can understand what im trying to do any help would be amazing
PHP:
Public Function bayinuse()
Dim bay As String
Dim num As Integer
Dim txtbay As String
Dim rs As Recordset
Dim lngred As Long
Dim lnggreen As Long
lngred = RGB(255, 0, 0)
lnggreen = RGB(0, 255, 0)
Set rs = CurrentDb.OpenRecordset("tblbays", dbOpenSnapshot, dbReadOnly)
Do While num < 14
num = num + 1
bay = "bay " + CStr(num)
txtbay = "Forms![frmbaydisplay].[txtbay" + num + "]"
Do While rs!bay <> bay
rs.FindNext
Loop
If rs!inuse = True Then
txtbay.BackColor = lngred
ElseIf rs!inuse = False Then
txtbay.BackColor = lnggreen
End If
rs.MoveFirst
Loop
End Function
thanks in advance
Last edited: