Show control on continuous subform row based on a condition

R

RLN

Hello.

RE: Access 2003

I have a main form that also contains a subform. This subform is set up as
a continuous form. When the main form (and subform) loads, I run some SQL in
the form open event to set its recordsource. After the load event has
finished, i need to look at the rows in the subform, and if the Resource
Notes field for a row (hidden on the subform row) contains information, I
need to make a button visible on that same row that says, "View Resource
Notes". Is there a way to do this when the form loads?

Thanks.
 
M

Marshall Barton

RLN said:
RE: Access 2003

I have a main form that also contains a subform. This subform is set up as
a continuous form. When the main form (and subform) loads, I run some SQL in
the form open event to set its recordsource. After the load event has
finished, i need to look at the rows in the subform, and if the Resource
Notes field for a row (hidden on the subform row) contains information, I
need to make a button visible on that same row that says, "View Resource
Notes". Is there a way to do this when the form loads?


No, you can not make a continuous subform control
visible/invisible on individual rows. OTOH, you can use
Conditional Formatting on a locked text box (set to look
like a button) to Enable/disable the simulated button.
 
R

RLN

Conditional Formatting on a locked text box <<

Do you have an example of how this would be done?

Thank you.
 
M

Marshall Barton

RLN said:
Do you have an example of how this would be done?


Just create a text box the same size as the button. Set its
properties:
BackColor -2147483633 (note the minus sign)
SpecialEffect Raised
TextAlign Center
ControlSource ="button caption"
Locked No (said the wrong thing before)
TabStop No

Now use the Format - Conditional Formatting menu item.
Select
Expression Is
in the drop box, enter the expression
[Resource Notes] Is Null
and click in the Enable button at the right of the
formatting choices.

If you switch the form to Form view, the text box should
look a lot like a button and be grayed out on records with
nothing in the notes field.

Once you have the text box looking as best you can, drag it
to the same position as the command button and use the
Format - Send to Back menu item to put the text box behind
the button.

Finally, set the button's Transparent property to Yes and
add a line of code at the top of the button's Click event
procedure:
If IsNull([Resource Notes]) Then Exit Sub
 
R

RLN

Marshall, this solution you posted here worked wonderfully! Thank you for
your assistance here.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top