Show/Hide Control - Which Event?

  • Thread starter Thread starter ScottA
  • Start date Start date
S

ScottA

I have added a button to a continuous form that lets the
user copy a record. The control is currently available
for any record on the form, including the blank 'new
record' line. I only want the user to be able to copy the
last record in the form, and hide the button on all of the
other lines.

Is there an approach to this that anybody has worked with?

I appreciate your thoughts and suggestions.

Scott A
 
Not possible AFAIK in the Detail section of the Form in CtsFormView. The
reason is that you see many instances of the *same* Control and the
instances are either *all* visible or all invisible.

HTH
Van T. Dinh
MVP (Access)
 
Hi Scott,

I would suggest adding the button to the header or footer of the form. The
button's code should be written to operate on the current record so there is
never any question of which row is being cloned. You can use Current event
of the form to toggle the Enabled property in order to disable the button on
a new record:

me.cmdClone.enabled = not me.newrecord

Then use the AfterUpdate event to toggle it again.

me.cmdClone.enabled = not me.newrecord

Note that above statement is just a abbreviation of the logic in these
statements:

if me.newrecord then
me.cmdClone.enabled=false
else
me.cmdclone.enabled=true
endif

Any modification to the properties of a control in the detail section will
be apparent on all rows of a continuous subform since there is just one
control - just multiple copies of the control are displayed. With most
controls we can use conditional formatting to get around this (Access 2000
and above) but CF doesn't work on command buttons.
 
Sandra,

Thanks so much for the suggestion - moving the button to
the footer takes it out of the continuous form which makes
it disappear from each record. This will be very useful!

Scott
-----Original Message-----
Hi Scott,

I would suggest adding the button to the header or footer of the form. The
button's code should be written to operate on the current record so there is
never any question of which row is being cloned. You can use Current event
of the form to toggle the Enabled property in order to disable the button on
a new record:

me.cmdClone.enabled = not me.newrecord

Then use the AfterUpdate event to toggle it again.

me.cmdClone.enabled = not me.newrecord

Note that above statement is just a abbreviation of the logic in these
statements:

if me.newrecord then
me.cmdClone.enabled=false
else
me.cmdclone.enabled=true
endif

Any modification to the properties of a control in the detail section will
be apparent on all rows of a continuous subform since there is just one
control - just multiple copies of the control are displayed. With most
controls we can use conditional formatting to get around this (Access 2000
and above) but CF doesn't work on command buttons.

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

I have added a button to a continuous form that lets the
user copy a record. The control is currently available
for any record on the form, including the blank 'new
record' line. I only want the user to be able to copy the
last record in the form, and hide the button on all of the
other lines.

Is there an approach to this that anybody has worked with?

I appreciate your thoughts and suggestions.

Scott A

.
 
Back
Top