Dynamically change form control value

StuLux

Well-known Member
Joined
Sep 14, 2005
Messages
643
Office Version
  1. 365
Platform
  1. Windows
I'm not sure if I am trying to do something impossible or whether I am approaching the problem in completely the wrong way:

I have a form which is designed to be completed and printed off for signing. There is a sub-form which will detail any risks that are open and I have placed a text box that states that if there are any open risks they will be listed, if there are no risks the sub-form is empty. I would prefer to make this a bit more intuitive and have the text box categorically state when there are no risks and, if there are live risks, how many.

I'm pretty sure I need ot use DCount but can I change the value of a textbox in this way or do I need some other form of control on the form? I didn't really want to store this number anywhere.
 

Some videos you may like

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

Andrew Fergus

MrExcel MVP
Joined
Sep 9, 2004
Messages
5,432
Hi Stuart

Is each risk stored separately within another table? If so, the DCount method will be the way to go. But rather than store the outcome (even if it is zero) in a linked control on your form/report, simply include the DCount as part of a statement to the same effect in an unbound box, e.g.

=IIF(DCount(......)=0, "There are no risks", "There is/are " & DCount(....) & "open risk(s)")

I haven't tested this but have used this technique before with success.

Andrew

More info on DCount here : http://msdn2.microsoft.com/en-us/library/Aa211471(office.11).aspx
 

Watch MrExcel Video

Forum statistics

Threads
1,122,691
Messages
5,597,562
Members
414,156
Latest member
WDMix

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top