Conditional formatting doesn't seem to work on opening a form

User avatar
Peter Kinross
5StarLounger
Posts: 962
Joined: 09 Feb 2010, 00:33
Location: Patterson Lakes, Victoria, Australia

Conditional formatting doesn't seem to work on opening a form

Post by Peter Kinross »

On a continuous form, I have some text box controls that are enabled or unenabled by conditional formatting, depending on the value of a Toggle control. The Toggle default is ‘False’, which should make the text boxes unenabled. On opening, I assumed that those text boxes would show as unenabled, but they don’t. If I click a the toggle, then all the records then show enabled/unenabled as they should. If I set the text box to unenbaled as default, then the Toggle does nothing when clicked – the text box remains unenabled.
A work around is to toggle the three Toggle controls twice on opening:

Code: Select all

NWOnOff = Nz(Me![tglNWReqd?])
IPOnOff = Nz(Me![tglIPReqd?])
InsOnOff = Nz(Me![tglInsReqd?])
Me![tglNWReqd?] = Not NWOnOff
Me![tglNWReqd?] = NWOnOff
Me![tglIPReqd?] = Not IPOnOff
Me![tglIPReqd?] = IPOnOff
Me![tglInsReqd?] = Not InsOnOff
Me![tglInsReqd?] = InsOnOff
This works. (sorry, can't find the 'Code' button)
Avagr8day, regards, Peter

User avatar
HansV
Administrator
Posts: 78378
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Conditional formatting doesn't seem to work on opening a form

Post by HansV »

Are the toggle controls bound to fields in the record source? If not, you have to run code in the Form_Load or Form_Open event.
Best wishes,
Hans

User avatar
Peter Kinross
5StarLounger
Posts: 962
Joined: 09 Feb 2010, 00:33
Location: Patterson Lakes, Victoria, Australia

Re: Conditional formatting doesn't seem to work on opening a form

Post by Peter Kinross »

Yes they are bound to fields in the record source.
Avagr8day, regards, Peter

User avatar
HansV
Administrator
Posts: 78378
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Conditional formatting doesn't seem to work on opening a form

Post by HansV »

Sorry, I can't explain that.
Best wishes,
Hans

User avatar
Peter Kinross
5StarLounger
Posts: 962
Joined: 09 Feb 2010, 00:33
Location: Patterson Lakes, Victoria, Australia

Re: Conditional formatting doesn't seem to work on opening a form

Post by Peter Kinross »

In that case it is absolutely unexplainable.
That workaround is working, so everything is going almost smoothly.
Thanks anyway Hans.
Avagr8day, regards, Peter