Reputation: 23
I am trying to make the caption of a button the content of a field from a table.
Everything I am finding online in forums and MS websites only shows using a macro with the OnClick
. I need it to display without every clicking. It also needs to dynamically change every time the field from the table changes.
How can I achieve this? Again, I don't want an event such as OnClick
, I want it to simply read as the field from the table reads.
Upvotes: 0
Views: 5858
Reputation: 2185
You could simply use the Form's OnCurrent
event to set the buttons caption.
On Current:
Private Sub Form_Current()
If Nz(Me.FieldName, "") <> "" Then
Me.btnTest.Caption = Me.FieldName
Else
'Handle blank record here
End If
End Sub
This will make it so ever time the selected record changes the button will update. Also just add the code into the specific field's AfterUpdate
event so it changes then as well.
After Update:
Private Sub Textbox1_AfterUpdate()
If Nz(Me.FieldName, "") <> "" Then
Me.btnTest.Caption = Me.FieldName
Else
'Handle blank record here
End If
End Sub
Upvotes: 3