I have multiple Command Buttons that call another UserForm to pick a date - currently I have separate Private Subs for each button ...
But is there a way to do this using the cmdName (where cmdName is the actual name of the button) as a variable eg ...
Thanks ...
VBA Code:
Private Sub cmdIncidentDate_Click()
Dim dateVariable As Date
dateVariable = CalendarForm.GetDate
If dateVariable <> 0 Then
Me.txtIncidentDate.Text = Format(CLng(dateVariable), "dd/mm/yyyy")
End If
End Sub
Private Sub cmdReportedDate_Click()
Dim dateVariable As Date
dateVariable = CalendarForm.GetDate
If dateVariable <> 0 Then
Me.txtReportedDate.Text = Format(CLng(dateVariable), "dd/mm/yyyy")
End If
End Sub
But is there a way to do this using the cmdName (where cmdName is the actual name of the button) as a variable eg ...
Code:
Private Sub cmdName_Click()
Dim dateVariable As Date
dateVariable = CalendarForm.GetDate
If dateVariable <> 0 Then
Me.txtName.Text = Format(CLng(dateVariable), "dd/mm/yyyy")
End If
End Sub
Thanks ...