LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 203
Default Do Until - If-then problem

"jeff" wrote in message
...

I'll try this again. I just replied, but it didn't take
I apprecitate the replies I got. But, I just don't understand them
enough to know how to use the replies with what I have already. I'm
sure non of the suggestions were meant to replace my coding. But, as I
read them, I don't see how they could connect. Obviously I don't know
enough about the subject to see it.
Just to be clear on what I'm trying to do.
I want the user to fill in some or all of the 16 TextBoxes. After
that, the total of those will be added, and placed in TextBox 23. What
I want is for TextBox 23 to be compared to TextBox 22. If the values
are exactly the same, then it runs AllocateDeposit module. If they DO
NOT equal, then I want that message box to come up again, then the
user tries it again (by changing some of the entries in those 16
TextBoxes. Then he clicks OK again, and TextBoxes 22 & 23 are compared
gain.... this goes on over and over until TextBoxes 22 & 23 are
equal.
If someone could please enlighten me, I would appreciate it. Thanks
for the replies so far.
jeff


*******

Jeff, I think I understand what you want to happen. From your OP:

***this attempt calculates the sum of the 16 TextBoxes, and shows that
number in TextBox23. And, it will recalculate the TextBox23 correctly
after each change by the user. So far, so good.

-- Sounds like your Click event doesn't need to care what the user has
done -- it simply tests your final condition and either displays the
message box and does nothing, or it executes the AllocateDeposit
procedure. (Question: how are you "proceeding to the next step" after
the test condition is met? Is that accomplished from within your
AllocateDeposit procedure? If so, you could be running into a problem
because you have not yet exited from the click event when you call
AllocateDeposit. But, that isn't the question I'm reading.)

However, when the
number finally does match, it still comes up with the MsgBox and
doesn't seem to re-test the IF-Then condition again. No matter what,
the MsgBox will come up.

Also, if TextBoxes 22 & 23 DO match on the
1st try, it still comes up with the MsgBox.

-- I've never attempted quite what you're describing, so my suggestion
is a guess at what the trouble might be. First off, set a breakpoint
[ Debug | Toggle Breakpoint ] at your IF statement and use the
immediate and locals windows to examine the contents of TextBox22.Value
and TextBox23.Value. [The Immediate and Locals windows are in the View
menu in the VBE window.]

Try changing your click event as follows and see if this helps:

Private Sub CommandButton1_Click() 'OK
Dim curBox23 As Currency
Dim curBox22 As Currency

ChkTotal 'sub in same UF
' that sums the total of the 16 TextBoxes

curBox22 = TextBox22.Value
curBox23 = TextBox23.Value

If (curBox23 - curBox22) < 0.0001 Then
'If TextBox23.Value = TextBox22.Value Then
AllocateDeposit 'Sub in same UF This final routine
'called only after TextBoxes 22 & 23 match.
Else
MsgBox "Total allocations must equal the Deposit value"
End If
End Sub


By converting the values to currency data types and then checking to see
if the difference between them is "small", I'm trying to avoid any
possible rounding errors or formating differences that could be causing
your test for equality to fail.

Post back if this doesn't clarify things for you.

HTH!

--
Clif McIrvin

(clare reads his mail with moe, nomail feeds the bit bucket :-)


 
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
Colon at the end of excel file name(ex: problem.xls:1, problem.xls financeguy New Users to Excel 2 January 15th 10 01:15 AM
Started out as an Access problem. Now an Excel problem RobertM Excel Discussion (Misc queries) 2 April 26th 06 07:30 PM
problem with a conditional max problem Brian Cornejo Excel Discussion (Misc queries) 1 February 18th 05 06:25 PM
Problem when multipple users access shared xl-file at the same time, macrocode for solve this problem? OCI Excel Programming 0 May 16th 04 10:40 PM


All times are GMT +1. The time now is 07:54 PM.

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

About Us

"It's about Microsoft Excel"