I have 2 different forms with multiple controls. The first form has textboxes that 'exit' when the enter key is pressed. The other form has textboxes, but they do not 'exit' on the enter key...Any ideas?
First form partial code: (tb_address and other textboxes all respond to the enter key by exiting)
The other form:tbNumofTypes does not respond to enter key:
All the textbox properties are the same for the textboxes in question...
TIA!
First form partial code: (tb_address and other textboxes all respond to the enter key by exiting)
Code:
Private Sub cbEndTime_Change()
cbEndTime.Value = Format(cbEndTime.Value, "h:mm AMPM")
cbEndTime.Value = IIf(cbEndTime.Value = "12:25 AM", "06:00", cbEndTime)
cbEndTime.Value = IIf(cbEndTime.Value = "12:05 AM", "12:00", cbEndTime)
LblPromoHours.Caption = "Est. Hours:"
LblPromoHours.Visible = True
LblEstHours.Caption = (DateDiff("n", cbStartTime.Value, cbEndTime.Value) / 60) * (DateDiff("d", DTPicker1, DTPicker2) + 1)
LblEstHours.Visible = True
txtSponsor.Visible = True
LblSponsor.Visible = True
txtSponsor.SetFocus
End Sub
Private Sub txtSponsor_Enter()
cbEndTime.Locked = True
If frmAgent.tb_AgtNo <> "" Then txtSponsor.Value = frmAgent.tb_AgtNo & " - " & frmAgent.tb_AgentName
End Sub
Private Sub txtSponsor_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If AllowExit = True Then Exit Sub
If txtSponsor.Value = "" Then
Cancel = True
txtSponsor.SetFocus
Exit Sub
End If
txtSponsor.Value = StrConv(txtSponsor.Value, vbProperCase)
tb_Address.Visible = True
lblAddress.Visible = True
tb_Address.SetFocus
End Sub
Private Sub tb_Address_Enter()
txtSponsor.Locked = True
If frmAgent.tb_AgtAddr <> "" Then tb_Address.Value = frmAgent.tb_AgtAddr
End Sub
Code:
Private Sub UserForm_Initialize()
cb_CouponType.RowSource = "Coupons"
tbNumofTypes.SetFocus
End Sub
Private Sub tbNumofTypes_Enter()
With tbNumofTypes
.SelStart = 0
.SelLength = Len(.Text)
End With
End Sub
Private Sub tbNumofTypes_Change()
If TypeName(Me.ActiveControl) = "TextBox" Then
With Me.ActiveControl
If Not IsNumeric(.Value) And .Value <> vbNullString Then
MsgBox "Sorry, only numbers allowed"
.Value = vbNullString
End If
End With
End If
End Sub
Private Sub tbNumofTypes_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If AllowExit = True Then Exit Sub
If tbNumofTypes.Value = "" Or tbNumofTypes.Value = 0 Then
Cancel = True
tbNumofTypes.SetFocus
Exit Sub
End If
lblCouponType.Visible = True
cb_CouponType.Visible = True
cb_CouponType.SetFocus
End Sub
Private Sub cb_CouponType_Enter()
tbNumofTypes.Locked = True
End Sub
TIA!