From: Braiock on 27 Apr 2010 17:12 Hello, I have a simple form in which I have a checkbox that makes a text field visible when the checkbox is checked (The text field is not bound). My problem is that when I switch to the next record the checkbox gets updated along with the record but the text field does not change along with the checkbox; if the next record has the checkbox unchecked the text box will still stay visible. Here is what code I have: Private Sub Check19_AfterUpdate() Me![Text22].Visible = Me!Check19 Me![Attachment29].Visible = Me!Check19 End Sub Private Sub Form_Current() Me![Text22].Visible = Me!Check19 Me![Attachment29].Visible = Me!Check19 End Sub Thank you for any help you can provide
From: Tore on 27 Apr 2010 18:06 If your form is a datasheet of continuous form all of the records in your table will be visible at once. Since the text field is not bound and not connected to a specific record it will either be visible in all records or invisible in all records. If you display your data in a normal form, i.e. one table record at a time, you can make the text field visible or invisible depending on your checkbox. For this purpose you make use of the "on current" event. This event fires every time the user changes from one record to another. In addition to the code in the "after update" event you should put the same code in the "on current event". Regards "Braiock" wrote: > Hello, > > I have a simple form in which I have a checkbox that makes a text field > visible when the checkbox is checked (The text field is not bound). My > problem is that when I switch to the next record the checkbox gets updated > along with the record but the text field does not change along with the > checkbox; if the next record has the checkbox unchecked the text box will > still stay visible. > > Here is what code I have: > > Private Sub Check19_AfterUpdate() > Me![Text22].Visible = Me!Check19 > Me![Attachment29].Visible = Me!Check19 > End Sub > > Private Sub Form_Current() > Me![Text22].Visible = Me!Check19 > Me![Attachment29].Visible = Me!Check19 > End Sub > > Thank you for any help you can provide
From: Tore on 27 Apr 2010 18:13 Sorry, I was too quick I see you use the on current event already. That should do the trick for normal forms. For datasheets and continuous forms I dont think it can be done unless you make the text field bound. Regards
From: John W. Vinson on 27 Apr 2010 19:36 On Tue, 27 Apr 2010 14:12:01 -0700, Braiock <Braiock(a)discussions.microsoft.com> wrote: >Hello, > >I have a simple form in which I have a checkbox that makes a text field >visible when the checkbox is checked (The text field is not bound). My >problem is that when I switch to the next record the checkbox gets updated >along with the record but the text field does not change along with the >checkbox; if the next record has the checkbox unchecked the text box will >still stay visible. > >Here is what code I have: > >Private Sub Check19_AfterUpdate() >Me![Text22].Visible = Me!Check19 >Me![Attachment29].Visible = Me!Check19 >End Sub > >Private Sub Form_Current() >Me![Text22].Visible = Me!Check19 >Me![Attachment29].Visible = Me!Check19 >End Sub > >Thank you for any help you can provide For an unbound control on a continuous or datasheet form, there's really only one textbox, displayed many times; changing its visible property in the Current event will change all the displayed instances. What you can do is use the Format... Conditional Formatting feature to set the foreground color equal to the background color based on the checkbox's value. -- John W. Vinson [MVP]
|
Pages: 1 Prev: Regulating available options Next: Search form with a checkbox. |