Code Repeats Itself And Goes To Wrong Focus

M

Minitman

Greeting,

For some reason this code repeats itself and then sets the focus on
the cancel button. TB2 is a date entry box. LDate2 is a cell that
contains the date that is updated in line 2. I change the background
color as a visual clue.


Private Sub TB2_Exit(ByVal Cancel As MSForms.ReturnBoolean)

MsgBox "Start"

Range("LDate2").Value = TB2.Value
TB2.Text = Format(DateValue(TB2.Text), "mmm dd, yyyy")
TB2.BackColor = &H80FFFF
EntryFormatLabel.Visible = False
BankFrame.Visible = True
BankFrame.SetFocus
'The labels, TextBoxes(TBn) and ComboBoxes(CBoxn) are all on this
Frame
If ESBox1.Text = "Bank Statement" Then
MsgBox "Bank Statement"
BankNameLabel.Visible = True
CBox1.Visible = True
BankAccountLabel.Visible = True
CBox3.Visible = True
BSDepAmountLabel.Visible = True
TB3.Visible = True
DTDepAmountLabel.Visible = False
TB4.Visible = False
MsgBox "End Bank Statement"
End If

If ESBox1.Text = "Non Bank Item" Then
MsgBox "Non Bank Item"
End If

If ESBox1.Text = "Deposit Ticket" Then
MsgBox "Deposit Ticket"
BankNameLabel.Visible = True
CBox1.Visible = True
BankAccountLabel.Visible = True
CBox3.Visible = True
BSDepAmountLabel.Visible = False
TB3.Visible = False
DTDepAmountLabel.Visible = True
TB4.Visible = True
MsgBox "End Deposit Ticket"
End If

End Sub

I choose one of three buttons and to change the contents of ESBox1
("Bank Statement", "Non Bank Item" and "Deposit Ticket"). I put in
the MsgBoxes to track the codes progress. That is when I noticed that
everything was running twice!!! At the end, I need the focus set to
the first tab stop inside the frame. With the way this code is
written, the focus goes outside of the frame to the cancel button.

Anyone have any ideas as to where I messed up?

Any help would be most appreciated.

TIA

-Minitman
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top