Home |
Search |
Today's Posts |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
"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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Colon at the end of excel file name(ex: problem.xls:1, problem.xls | New Users to Excel | |||
Started out as an Access problem. Now an Excel problem | Excel Discussion (Misc queries) | |||
problem with a conditional max problem | Excel Discussion (Misc queries) | |||
Problem when multipple users access shared xl-file at the same time, macrocode for solve this problem? | Excel Programming |