Enable Form Control Advice

PNGBill

Win10 Office Pro 2016
Local time
Tomorrow, 03:16
Joined
Jul 15, 2008
Messages
2,269
I have a mainform and subform.
The mainform has command buttons that will filter the data to the subform.
One filter has the Continuous subform with two types of data.
One has textbox control "LID" with 0 (zero) and the other has numbers above zero. LID is on the continuous subform. Only filter buttons on the main form.
A Command Button on each record I would like to be either visible or not or enabled or not.
Visible if LID >0 - or enabled.
This is all from the main form filter button.
This line on the filter button works to set the subform button to visible for all records in this data set - filtered view.
PHP:
[Me.FrmLoanApplicationsSubForm.Form.CmdLoanMoved.Visible = True/PHP]
How can I add an If then to make it either be visible or not depending on LID ??

I can get it to either be visible or not for all records but not just for some.

I also tried to set the enabled in the subform but so far no luck.
If I persued this, which event would you use?
On Enter ? I want it to not work for the onclick event if LID is zero.

I assume it is possible to have a continuous form with buttons showing / enabled on some records only?:confused:
 
The buttons on a continuous form are multiple renditions of the same button so they cannot be independently assigned properties.

Instead of using a button, use a textbox bound to the RecordSource.
Set the Special Effect property to Raised to look like a button.

Use Conditional formatting to set the text to grey as required.
In the OnClick event procedure of the textbox, test the same conditions of the current record and don't take the action if the "button" is not supposed to work.
 
Bill,

Further to Galaxiom's advice, I can also suggest that you can use Conditional Formatting to conditionally toggle the Enabled property of the "textbox masquerading as a command button", which is probably a simpler approach.
 
Thanks Guys for the advice.:)

This explains why I could only get the button to be one or the other.

Will try the text box option.
 
Works perfectly.
PHP:
=IIf([LID]=0,"Disabled","Forward")
as the text box control source makes the "button" label either Foward or Disabled.

Conditional Formatting has the button either enabled or disabled (greyed) depending on if Forward or Disabled is shown.

On Click event runs the code only when "Forward" is displayed.

The original filter code in the main form just required the control source name to be updated so the "button" is visible or not in the different filter options and Wala, it all works.
Appreciate the tip.:)
 
Awesome, Bill. Sweet when you get stuff to work how you want, isn't it?
 
Oh Yes.:) Especially after a few hours of head banging:(
 
It is worth remembering just how versatile the humble textbox can be.

Another trick they can do is masquerade as a Label. It is a fantastic way to implement labels in multilanguage applications. The "label" captions are included in the RecordSource query joined on the registered language of the logged in user and then shown in bound textboxes.

Just turn off the border, disable and lock, set the backcolor to the same as the form and they look exactly like a label but with all the features of conditional formatting thrown in too.

You can even have continuous forms with different labels for each record using this technique.
 
Another place where I often use a textbox to mimic a label is on reports where you want Can Shrink to work in the case of the attached data control having no data, use a "label" with Control Source:
=IIf(IsNull([MyDataField]),Null,"My label text")
 

Users who are viewing this thread

Back
Top Bottom