option group issue

campanellisj

Registered User.
Local time
Today, 07:14
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
 
From what you are describing it sounds like you are using a continuious form is this correct?
 
yes that is correct
 
When you use this type of form then each control is treated the same for all records as there is actually only 1 set of controls which are replicated for all the records. You may need to look at Conditional Formatting on your controls.
 
I thought of this but in design mode the conditional formatting is not avalible for the option group.
I would really not want to use single forms is there another way to accomplish this?
 
You would apply it on the controls which appearance you want to change.
 
sorry I am totally confused now.
how do I apply a condition to make the cboduration box visible if the optleave is 1
 

Users who are viewing this thread

Back
Top Bottom