Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,566
- Office Version
- 365
- 2016
- Platform
- Windows
I have a commandbutton (uf8b_cancel) on my userform (uf8b_postcomm), that when pressed will clear values of a second userform (uf8_post), essentially "re-initializing" uf8_post. I don't need to actually initialize that form as during the initialization there are fields that are unachanged and would just be recalculated again.
The way I have thought to do this is to trigger a textbox change event in uf8_post by assigning that field a value.
By assigning a value to a textbox, will that trigger it's change event? As I have it now, it isn't ....
My button code from uf8b_postcomm
The above is supposed to change the value of uf8_post.uf8_rin (textbox) and thus forcing it's change event. The change evnt recognizes the value as being zero and clears the appropriate fields.
Is this not the best approach? Or is there an error in my coding?
The way I have thought to do this is to trigger a textbox change event in uf8_post by assigning that field a value.
By assigning a value to a textbox, will that trigger it's change event? As I have it now, it isn't ....
My button code from uf8b_postcomm
Code:
Private Sub uf8b_cancel_Click()
With uf8_post 'original userform
uf8_rin = "0" 'change textbox value forcing uf8_rin change event
End With
Unload uf8b_postcomm 'close this userform
End Sub
The above is supposed to change the value of uf8_post.uf8_rin (textbox) and thus forcing it's change event. The change evnt recognizes the value as being zero and clears the appropriate fields.
Code:
Private Sub uf8_rin_Change()
Dim s_rin As String
Dim rin As Long
Dim t_row As Long 'target row
s_rin = uf8_prin.Value & uf8_rin
rin = s_rin * 1
t_row = Application.WorksheetFunction.Match(rin, ws_psttemp.Range("A:A"), 0)
If uf8_rin.Value = "0" Then
With ws_psttemp
uf8_rin.Value = ""
uf8_rin.BackColor = RGB(0, 168, 232)
uf8_tstat.BackColor = vbWhite
uf8_d_contract = ""
uf8_d_start = ""
uf8_d_end = ""
uf8_d_event = ""
uf8_d_league = ""
uf8_d_cust = ""
uf8_d_fac = ""
End With
Else
With ws_psttemp
uf8_rin.BackColor = vbWhite
uf8_tstat.BackColor = RGB(0, 168, 232)
uf8_d_contract = .Range("F" & t_row)
uf8_d_start = format(.Range("G" & t_row), "h:mm AM/PM")
uf8_d_end = format(.Range("H" & t_row), "h:mm AM/PM")
uf8_d_event = " " & .Range("L" & t_row)
uf8_d_league = " " & .Range("M" & t_row)
uf8_d_cust = " " & Application.WorksheetFunction.VLookup(.Range("F" & t_row), ws_rd.Range("A:K"), 11, False)
uf8_d_fac = " " & .Range("C" & t_row) & " " & .Range("D" & t_row)
End With
End If
End Sub
Is this not the best approach? Or is there an error in my coding?