Enable/Disable Command Button on Each Row of Form in Tabular View

whdyck

Registered User.
Local time
Today, 12:16
Joined
Aug 8, 2011
Messages
169
I'm using MS Access 2003.

I have a form in Tabular (Continuous) View, so there are many records displayed at a time. I would like to add a command button to each row, enabled or disabled based on the nullness of a specific field on each record. I cannot seem to make it work.

Here's the code in the form's Open event:

Code:
Private Sub Form_Load()
If IsNull(txtCsrArchiveDetailId) Then
    Me.cmdReStageRecord.Enabled = True
Else
    Me.cmdReStageRecord.Enabled = False
End If
End Sub
This code seems to fire only once (for the first record, I suppose), then makes all the command buttons enabled or not based on that first record.

What am I doing wrong?

Thanks for any help you can give.

Wayne
 
One of the quirks of continuous forms is that All occurrences of a Control will be effected by code that is based on the current records.
 
Is there a workaround or alternative approach to accomplish basically the same thing?

Wayne
 
Are you certain you need the button on every row? If you put the button in the header or footer, you can set its enabled property by placing your code in the Current event. This way, the button's status will depend on the values in the currently selected row. :)


Code:
Private Sub Form_Current()
    txtCurrent = Field1
End Sub

txtCurrent is a textbox in the footer of a continuous form. Its value changes to match that of Field1 in whichever row is current.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom