Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default SetFocus Issue

I'm tring to write a simple routine to automate a group's "paper 'n napkin"
bookkeeping. They have several revenue streams, coffee, copy machine,
ceramics, membership, etc. I'm setting the input up to match what they are
presently doing on paper (You know the group I'm talking about when you hear
them say "Well we've done it this way for the last 20 years..."). Enough
said.
In the situation below, they would first count the funds for the particular
item, in this case, one source of coffee income, and input the information
into a text box. Then they recount, separating out checks, cash, and coin
individually (see excuse above as to why I'm not fighting them). This is a
double check. At least I convinced them to let Excel do the math. Each of
the inputs, check, cash, and coin values, are running very similar
subroutines that total rows and columns on form and each with the exception
of the "coin" routine, see below, perform fine.

Private Sub txtCoffeeSubCoin_AfterUpdate()

txtCoffeeSubCoin.Value = Format(Val(txtCoffeeSubCoin.Value), _
"$#,##0.00") 'fomats value in current txtbox
txtCoffeeMainCoin.Value = Format(Val(Mid(txtCoffeeSubCoin.Value, 2)) + _
Val(Mid(txtBingoSubCoin.Value, 2)), "$#,##0.00") 'combines both
income sources onto main income line and formats
TotalsColCoin 'totals the coin count column
TotalsCoffeeRow 'totals the main income source line
CBBingoSub.SetFocus 'sets the focus to a checkbox that turns the
visibility of the next line item's txtboxes on

End Sub

My problem is with the SetFocus line. As mentioned, the other similar
routines seem to handle the setfocus OK, tho they are setting focus on the
next txtbox in order, but when the line in question is executed, the program
jumps back to the beginning of the subroutine and reruns itself, clearing the
entry. I've commented out the line and the routine finishes like it should

Any help is appreciated. JG
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 257
Default SetFocus Issue

I could be wrong, but I think you're missing this only because
it's so obvious. The routine runs whenever txtCoffeeSubCoin is
updated, and the routine updates txtCoffeeSubCoin; so when it
sets the focus somewhere else Excel figures txtCoffeeSubCoin
is now officially updated and starts the txtCoffeeSubCoin_AfterUpdate
routine. Don't you think?

--- "John G." wrote:
Private Sub txtCoffeeSubCoin_AfterUpdate()
txtCoffeeSubCoin.Value = "<something, anything"
.
.
.
CBBingoSub.SetFocus 'sets the focus to a checkbox
End Sub

My problem is with the SetFocus line. As mentioned, the other similar
routines seem to handle the setfocus OK, tho they are setting focus on the
next txtbox in order, but when the line in question is executed, the program
jumps back to the beginning of the subroutine and reruns itself....

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default SetFocus Issue

I see your point regarding the fact that the formating is again updating the
txtbox BUT...all the other "_AfterUpdate" routines in the Userform use the
identical format line (tho txtbox name specific) and they don't appear to
have any problem. Regarding the 2nd time the routine runs, it clears the
value (maybe because it's already formatted) and finishes with a setfocus
somewhere else then the checkbox that's specified.


"Bob Bridges" wrote:

I could be wrong, but I think you're missing this only because
it's so obvious. The routine runs whenever txtCoffeeSubCoin is
updated, and the routine updates txtCoffeeSubCoin; so when it
sets the focus somewhere else Excel figures txtCoffeeSubCoin
is now officially updated and starts the txtCoffeeSubCoin_AfterUpdate
routine. Don't you think?

--- "John G." wrote:
Private Sub txtCoffeeSubCoin_AfterUpdate()
txtCoffeeSubCoin.Value = "<something, anything"
.
.
.
CBBingoSub.SetFocus 'sets the focus to a checkbox
End Sub

My problem is with the SetFocus line. As mentioned, the other similar
routines seem to handle the setfocus OK, tho they are setting focus on the
next txtbox in order, but when the line in question is executed, the program
jumps back to the beginning of the subroutine and reruns itself....

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
Simple SetFocus on userform issue SMS Excel Programming 6 October 2nd 09 12:09 AM
SetFocus issue JT Excel Programming 0 April 13th 09 05:12 PM
SetFocus? plh Excel Programming 1 May 1st 06 03:01 AM
Form, SetFocus and AfterUpdate issue Piers 2k Excel Programming 2 November 8th 05 01:52 PM
setfocus Dean Reardon Excel Programming 2 December 15th 04 12:18 PM


All times are GMT +1. The time now is 04:13 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"