When I open my form there are two fields and a calendar button that I want to be hidden. When check box is clicked I want these fields and the button to become visible. I already tried a few things, on click, on open If Field = "Yes" Then Field.Visible = True Else Field.Visible = False End If The fields I specify disappear but don't reappear when I check the box.
In a check box, -1 is a yes and 0 is a no. Try IF field = -1 then "mel" wrote: > When I open my form there are two fields and a calendar button that I want to > be hidden. When check box is clicked I want these fields and the button to > become visible. I already tried a few things, on click, on open > If Field = "Yes" Then > Field.Visible = True > Else > Field.Visible = False > End If > The fields I specify disappear but don't reappear when I check the box. >
This might be simpler: chkBox_Click() 'click event of a check box txt1.Visible = chkBox 'a text box on the form cbo1.Visible = chkBox 'a combo box on the form btn1.Visible = chkBox 'a button on the form End Sub When checking the box, you are setting its value to True, when unchecking it, you set it to False, so each of these applies to the .Visible property of the other controls. "mel" wrote: > When I open my form there are two fields and a calendar button that I want to > be hidden. When check box is clicked I want these fields and the button to > become visible. I already tried a few things, on click, on open > If Field = "Yes" Then > Field.Visible = True > Else > Field.Visible = False > End If > The fields I specify disappear but don't reappear when I check the box. >
Hi Brian, That works great!...except how do I make the boxes be hidden when I open a new record. When I open a new record the fields are there and I have to check and then un-check the box to make them disappear. "Brian" wrote: > This might be simpler: > > chkBox_Click() 'click event of a check box > txt1.Visible = chkBox 'a text box on the form > cbo1.Visible = chkBox 'a combo box on the form > btn1.Visible = chkBox 'a button on the form > End Sub > > When checking the box, you are setting its value to True, when unchecking > it, you set it to False, so each of these applies to the .Visible property of > the other controls. > > "mel" wrote: > > > When I open my form there are two fields and a calendar button that I want to > > be hidden. When check box is clicked I want these fields and the button to > > become visible. I already tried a few things, on click, on open > > If Field = "Yes" Then > > Field.Visible = True > > Else > > Field.Visible = False > > End If > > The fields I specify disappear but don't reappear when I check the box. > >
Something like this. It makes them invisible on new records but visible on exisitng records. Private Sub Form_Current() If Form.NewRecord Then chkBox = False 'unchecks the box Else chkBox = True 'checks the box End If chBox_Click 'runs the code from that event, which sets the Visible properties End Sub "mel" wrote: > Hi Brian, > That works great!...except how do I make the boxes be hidden when I open a > new record. When I open a new record the fields are there and I have to check > and then un-check the box to make them disappear. > > "Brian" wrote: > > > This might be simpler: > > > > chkBox_Click() 'click event of a check box > > txt1.Visible = chkBox 'a text box on the form > > cbo1.Visible = chkBox 'a combo box on the form > > btn1.Visible = chkBox 'a button on the form > > End Sub > > > > When checking the box, you are setting its value to True, when unchecking > > it, you set it to False, so each of these applies to the .Visible property of > > the other controls. > > > > "mel" wrote: > > > > > When I open my form there are two fields and a calendar button that I want to > > > be hidden. When check box is clicked I want these fields and the button to > > > become visible. I already tried a few things, on click, on open > > > If Field = "Yes" Then > > > Field.Visible = True > > > Else > > > Field.Visible = False > > > End If > > > The fields I specify disappear but don't reappear when I check the box. > > >