03856me
Active Member
- Joined
- Apr 4, 2008
- Messages
- 297
Excel 2007 - UserForm
From my main menu which is simply shapes with macros attached I launch the userform. Upon the first try, and not always, just sometimes, when I get to txt_vc1, it freezes and I am not allowed to move to the next textbox. I can still use my Exit button on the UserForm to unload the form and then go back in the same way and it works. Could someone help point me to what might be happening please?
Here is the code associated with the userform and textbox that is causing the problem.
Macro to Load UserForm
UserForm Initialize Code
TextBox Change Event Code
TextBox Enter Exit Event Code
IsValidID Function Code
Thanks in Advance for Your Help!
From my main menu which is simply shapes with macros attached I launch the userform. Upon the first try, and not always, just sometimes, when I get to txt_vc1, it freezes and I am not allowed to move to the next textbox. I can still use my Exit button on the UserForm to unload the form and then go back in the same way and it works. Could someone help point me to what might be happening please?
Here is the code associated with the userform and textbox that is causing the problem.
Macro to Load UserForm
Code:
Sub EnterEdit()
Frm_Input.Show False
End Sub
UserForm Initialize Code
Code:
Private Sub UserForm_Initialize()
Worksheets("data").Visible = True
Worksheets("data").Select
Range("A" & Rows.Count).End(xlUp).Select
ActiveSheet.Shapes("ReportMenu").Visible = False
Worksheets("Main Menu").Visible = False
End Sub
TextBox Change Event Code
Code:
Private Sub txt_vc1_change()
If txt_vc1.Value > 0 Then
Me.cmd_addVC.Visible = False
Me.lbl_vc2.Visible = True
Me.txt_vc2.Visible = True
End If
End Sub
TextBox Enter Exit Event Code
Code:
Private Sub txt_vc1_Enter()
txt_vc1.BackColor = &HC0C0C0
End Sub
Private Sub txt_vc1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
txt_vc1.BackColor = &HFFFFFF
Select Case IsValidID(txt_vc1)
Case True
Me.lbl_VCnote.Visible = False
Exit Sub
Case Else
txt_vc1.BackColor = &HFFFFFF
Me.lbl_VCnote.Visible = True
Beep
Me.txt_vc1.SetFocus
Me.cmd_addVC.Visible = False
Me.cmd_add.Visible = False
Me.cmd_addNegative.Visible = False
Me.txt_vc2.Visible = False
Me.lbl_vc2.Visible = False
Cancel = True
End Select
End Sub
IsValidID Function Code
Code:
Function IsValidID(sID) As Boolean
IsValidID = False
sID = CStr(sID)
If Not sID Like "########" Then Exit Function
Select Case Mid(sID, 1, 2)
Case 11 To 19, 21 To 39, 31 To 39, 99 To 99
Case Else
Exit Function
End Select
Select Case Mid(sID, 3, 2)
Case 10 To 40
Case Else
Exit Function
End Select
Select Case Mid(sID, 5, 2)
Case 3 To 60
IsValidID = True
Case Else
Exit Function
End Select
IsValidID = True
End Function
Thanks in Advance for Your Help!