campanellisj
Registered User.
- Local time
- Today, 07:22
- Joined
- Apr 28, 2010
- Messages
- 23
I know that there is probably a better way to write this code but this is what I have thus far and it works to a point.
I have an option group (optLeave), a combobox (cboDuration) and two text boxes (txtLvStart, txtLvStop)
I simply wanted the combobox and text boxes to be visible only if the value of the option group equaled 1 (yes) and be invisible if it was 2 (no).
This code worked but the problem I am having is it is affecting all my records not just the current one. If a user selects 1 (yes) in record one the boxes are visible in subsequent records as well and vice versa if the user selects 2 (No) the boxes are not visible in subsequent records (hiding the information for any other records that may be "yes"). How do I fix this to have the code only affect the crrent record and not all records?
If optLeave = 1 Then
cboDuration.Visible = True
txtLvStart.Visible = True
txtLvStop.Visible = True
Else: optLeave = 0
cboDuration.Visible = False
End If
If optLeave = 1 Then
cboDuration.Visible = True
txtLvStart.Visible = True
txtLvStop.Visible = True
Else: optLeave = 0
txtLvStart.Visible = False
End If
If optLeave = 1 Then
cboDuration.Visible = True
txtLvStart.Visible = True
txtLvStop.Visible = True
Else: optLeave = 0
txtLvStop.Visible = False
End If
End Sub
I have an option group (optLeave), a combobox (cboDuration) and two text boxes (txtLvStart, txtLvStop)
I simply wanted the combobox and text boxes to be visible only if the value of the option group equaled 1 (yes) and be invisible if it was 2 (no).
This code worked but the problem I am having is it is affecting all my records not just the current one. If a user selects 1 (yes) in record one the boxes are visible in subsequent records as well and vice versa if the user selects 2 (No) the boxes are not visible in subsequent records (hiding the information for any other records that may be "yes"). How do I fix this to have the code only affect the crrent record and not all records?
If optLeave = 1 Then
cboDuration.Visible = True
txtLvStart.Visible = True
txtLvStop.Visible = True
Else: optLeave = 0
cboDuration.Visible = False
End If
If optLeave = 1 Then
cboDuration.Visible = True
txtLvStart.Visible = True
txtLvStop.Visible = True
Else: optLeave = 0
txtLvStart.Visible = False
End If
If optLeave = 1 Then
cboDuration.Visible = True
txtLvStart.Visible = True
txtLvStop.Visible = True
Else: optLeave = 0
txtLvStop.Visible = False
End If
End Sub