G
Guest
I have a subform that shows data from a table in continous view. I have
created a button on the subform that goes with each record. When clicked,
the button adds data from the record to a second table. I would like to set
it up so that the button in disabled if the data from the record is already
in the second table.
I have written some VBA to do that, but the problem is that it seems to
update all of the buttons based on the first record, rather than updating
each button based on its associated record.
I have tried putting the code into several different events of the subform
(OnLoad, OnOpen, OnActivate, AfterLayout).
Here is the code:
If IsNull(DLookup("[X]", "Table2", "[X]='" & Me.[X].Value & "' AND [Y]='" & _
& Me.[Y].Value & "' AND [Z]='" & Me.[Z].Value & "'")) Then
Me.ButtonName.Enabled = False
Me.ButtonName.Caption = "On List"
Else
Me.ButtonName.Enabled = True
Me.ButtonName.Caption = "Add to List"
End If
Any ideas? Thanks.
created a button on the subform that goes with each record. When clicked,
the button adds data from the record to a second table. I would like to set
it up so that the button in disabled if the data from the record is already
in the second table.
I have written some VBA to do that, but the problem is that it seems to
update all of the buttons based on the first record, rather than updating
each button based on its associated record.
I have tried putting the code into several different events of the subform
(OnLoad, OnOpen, OnActivate, AfterLayout).
Here is the code:
If IsNull(DLookup("[X]", "Table2", "[X]='" & Me.[X].Value & "' AND [Y]='" & _
& Me.[Y].Value & "' AND [Z]='" & Me.[Z].Value & "'")) Then
Me.ButtonName.Enabled = False
Me.ButtonName.Caption = "On List"
Else
Me.ButtonName.Enabled = True
Me.ButtonName.Caption = "Add to List"
End If
Any ideas? Thanks.