Buttons for Each Row in a form

A

alomrani

Hi all ,

I'd appreciate anyone insight on this

I have created a form that fetched rows from a query. On each row I
have added buttons to execute command for that relevant row only. The
Form displays all rows fetched in tabular format.

Now one of the data fetched is a Yes/No Value , When it is true it
should hide some of the buttons and make some visible.

I have written that routine but I dont know on which event shall i
place it at. When I put it at (form on load) it says object undefined.
?! any clue

Private Sub is_approvedBox_(### What Event ###)(Cancel As Integer)

If (is_approvedBox.Value = -1) Then
QualifyLeaveCmd.Visible = False
DeleteLeaveCmd.Visible = False
PrintReport.Visible = False
EditLeaveCmd.Visible = True

Else
PrintReport.Visible = True
QualifyLeaveCmd.Visible = True
DeleteLeaveCmd.Visible = True
EditLeaveCmd.Visible = False
End If
End Sub


Will I also need to pass a variable to the button when i click it
stating which row it belongs to ?
I'm confused.


Thanks Again

Regards

Alya
 
A

Allen Browne

In a continuous form, you cannot hide the buttons on some rows but not on
others.

You may be able to simulate this if you used an unbound text box instead of
a command button. Set its Control Source to the text you want to appear as
the "label" on the button, e.g.:
="Click Me!"

You can then use Conditional Formatting (CF) of the text box to simulate a
disabled look, by changing the ForeColor to a grey and changing the
BackColor. The CF does work on different rows.
 
P

purpleflash

Hi there

A slightly left field take on this! but...

If you put your buttons elsewhere on the form rather than within the
record row itself and given that the action behind the button can
easily be made to apply only to the currently selected record then you
can switch the buttons on and off depending on the values in the
current record using the onOpen and onCurrent events to your hearts
content! I find it's rare that you need to have the buttons actually
inside the row itself especially when the user usually needs to select
a row anyway!

Purpleflash
 
Top