ClaraBarton
Registered User.
- Local time
- Today, 14:28
- Joined
- Oct 14, 2019
- Messages
- 623
This seems very simple but doesn't work. I have 4 textboxes with 4 buttons. When a button is clicked I want to copy the textbox content to another place. The code works if I place it in each click event but I'd like to combine the code into one function so I can add more. My problem is I can't figure out how to select the button. I've used string, control... I don't know how to create a variable for the buttons to use in the first line of Select Case. Error is object variable not set.
Code:
Public Function ToNoteButton()
Dim S As String
Dim CN As String
Dim Symbol As String
Dim CD As Date
Dim ctrl As Button
CN = Nz(Me.Parent.CNotes, "")
Select Case ctrl
Case Me.btnVM
CD = Nz(Me.VMDate)
Symbol = Chr(42)
Case Me.btnSI
CD = Nz(Me.SIDate)
Symbol = Chr(35)
Case Me.btnNC
CD = Nz(Me.NCDate)
Symbol = Chr(37)
Case Me.btnCT
CD = Nz(Me.CTDate)
Symbol = Chr(64)
End Select
If CD = 0 Then
Exit Function
Else: S = Symbol & CD
If IsNull(CN) Then
CN = S
Else: Me.Parent.CNotes = S & "<div>" & CN
End If
End If
Me.Parent.AddToNotes
End Function