I have this following userform that displays the GL account in gray before the user inputs an amount:
However, when this form launches, the cursor is in the first cell which then causes the format to switch to the format for after input has been received. Is there any way to have all three cells appear as the last two do? Here is my code:
Here is the code for after the cell is updated:
I know this is a minor UX issue but this project needs to be as polished as possible. Thanks for any help in advance!
However, when this form launches, the cursor is in the first cell which then causes the format to switch to the format for after input has been received. Is there any way to have all three cells appear as the last two do? Here is my code:
VBA Code:
Private Sub Userform_Initialize()
Me.Top = Application.Top + (Application.UsableHeight / 2) - (Me.Height / 2)
Me.Left = Application.Left + (Application.UsableWidth / 2) - (Me.Width / 2)
For a = 1 To 3
Me.Controls("txtAmount" & a).ForeColor = RGB(166, 166, 166)
Me.Controls("txtAmount" & a).TextAlign = fmTextAlignLeft
Next
Me.txtAmount1 = "GL A/C 7833"
Me.txtAmount2 = "GL A/C 7832"
Me.txtAmount3 = "GL A/C 7831"
End Sub
Here is the code for after the cell is updated:
VBA Code:
Private Sub txtAmount1_AfterUpdate()
Dim txt As Object
Set txt = Me.txtAmount1
txt.ForeColor = RGB(0, 0, 0)
txt.TextAlign = fmTextAlignRight
With txt
If IsNumeric(.Value) Then .Value = Format(.Value, "#,##0.00")
End With
If txt.Value = "" Then
txt.TextAlign = fmTextAlignLeft
txt.ForeColor = RGB(166, 166, 166)
txt.Value = "GL A/C 7833"
End If
End Sub
I know this is a minor UX issue but this project needs to be as polished as possible. Thanks for any help in advance!