PDA

View Full Version : VBA - Excel 2003 When i use vba Modeless form , textbox loose focus on exit event



ksingh26
01-25-2013, 01:37 AM
Hi ,

Need your help

I am opening my form using vbmodeless

On following Textbox6 exit event (in Form) i lose focus from TextBox6 and later I have to manually use mouse to put my cursor on form / textbox6


If I use form.show 0 (by removing vbmodeless) then it works perfect but then I cannot use other excel sheets open on my desktop


Please help me to resolve this issue. Textbox6 exit code mentioned as follows



Private Sub TextBox6_exit(ByVal Cancel As MSForms.ReturnBoolean)
If TextBox6.Text <> "" Then
If IsDate(TextBox6.Text) Then
TextBox6.Text = Format(TextBox6.Text, "mm/dd/yyyy")
If Me.TextBox6.Value <= Me.TextBox5.Value Then
Me.TextBox7.Text = Sheets("Master").Range("B53").Value
Me.TextBox7.Value = Format(TextBox7.Value, "$#,##0.00")
Else
MsgBox "Enter Effective date less than Pay To Date!", vbOKOnly + vbInformation, "Wrong Input"
Cancel = True
With UserForm1.TextBox6
.SetFocus
.SelStart = 0
.SelLength = Len(.Text)
End With
End If
Else
MsgBox "Please Enter a Effective Date in MM/DD/YYYY format!"
Cancel = True
End If

End If
End Sub



Thanks in advance
:banghead: :banghead:
Daya