Dear all,
I'm trying to write a generic code which would allow me to put a variable into me.Controls(Variable).text to specify the field value. I've tried to explain the problem below. Any help would be greatly appreciated.
Thank you in advance. MJC
Background:
My form has three fields: Myfield, MyField_A & MyField_B
Myfield_A and MyField_B are only available for selection if MyField = "Yes"
The code I'm trying to write would look at MyField and if is "yes" then it will make sure Fields A & B are enabled. If Myfield is = "No" then it will clear the values in fields A & B and then disable the fields.
The code is like this
' Beginning of Code
Select Case Me.MyField.Text
Case "Yes": iTF = True
Case Else: iTF = False
End Select
Dim i as variant
Dim iField as string: iField = ""
Dim iTF as boolan: iTF = false
For i = 1 to 2
Select Case i
Case 1: iField = "_A"
Case 2: iField = "_B"
End Select
if Not itf then Me.Controls(MyField & iField).Text =""
Me.Controls(MyField & iField).Enabled = itf
next
' End of Code
Note: This is a very simple example of the problem I'm trying to resolve.
I'm trying to write a generic code which would allow me to put a variable into me.Controls(Variable).text to specify the field value. I've tried to explain the problem below. Any help would be greatly appreciated.
Thank you in advance. MJC
Background:
My form has three fields: Myfield, MyField_A & MyField_B
Myfield_A and MyField_B are only available for selection if MyField = "Yes"
The code I'm trying to write would look at MyField and if is "yes" then it will make sure Fields A & B are enabled. If Myfield is = "No" then it will clear the values in fields A & B and then disable the fields.
The code is like this
' Beginning of Code
Select Case Me.MyField.Text
Case "Yes": iTF = True
Case Else: iTF = False
End Select
Dim i as variant
Dim iField as string: iField = ""
Dim iTF as boolan: iTF = false
For i = 1 to 2
Select Case i
Case 1: iField = "_A"
Case 2: iField = "_B"
End Select
if Not itf then Me.Controls(MyField & iField).Text =""
Me.Controls(MyField & iField).Enabled = itf
next
' End of Code
Note: This is a very simple example of the problem I'm trying to resolve.