Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 273
Default Code Repeats Itself And Goes To Wrong Focus

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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
copy and paste VBA repeats and repeats Marilyn Excel Discussion (Misc queries) 4 June 7th 09 03:49 PM
Form keep the focus unable to get to the code - HELP! Kaz G New Users to Excel 1 January 23rd 08 06:00 PM
Opens to form then keep focus and unable to get to code - HELP!! Kaz G Excel Discussion (Misc queries) 0 January 23rd 08 01:16 AM
What is wrong with this code? jlclyde Excel Discussion (Misc queries) 5 January 9th 08 05:12 PM
Running Code looses focus to Outlook and stops Steven Kelder Excel Programming 0 January 2nd 04 07:59 AM


All times are GMT +1. The time now is 06:00 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"