Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formula Problem 3

Status
Not open for further replies.

janetlyn

Technical User
Jan 29, 2003
516
US
I have the following code in a form:

ElseIf (([A21] <> ([E38] + [E58]))) Then
A21.Visible = True
E38.Visible = True
E58.Visible = True
CumNetPL.Visible = True
Line221.Visible = True
BoxA21E38E58.Visible = True

Obviously this is not all the code, just the relavent ones. If the formula above is not true A21 does not equal (E38+E58) all these fields become visible so the person knows there is an error. If they do equal, the formula goes on to the next ElseIf.

The problem:

A21=(1,455,426.61)
E38=1,000,000.00
E58=(2,455,426.61)

OR

A21=(1,455,426.61)
E38=(1,000,000.00)
E58=(455,426.61)

I have tried both ways and each time, the boxes become visible. I put the exact same formula in an excel spreadsheet and it said they were equal. How come Access does not think these numbers are equal? Any ideas?

Appreciate any help. Janet Lyn
 
Thanks Dan, I'm leaving but will be working on it this weekend, so we shall see. Have a great weekend. Janet lyn
 
hmmmmmmmmmmmmmmmm ... mmmmmmmmm,

I THINK that (in the debug window) you cannot use the &quot;[&quot; & &quot;]&quot; ('Square brackets'). If this is actually an Ms. A. App, the brackets refer to a field from a recordset. In my earlier post, I asked if the braketed variables were the same as the &quot;un-bracketed&quot; ones with the same 'names'. If the brackets indicate the Excell RC location of the information, I would expect the bracketed and unbracketed references to NOT be the same thus the unbracketed references would be simple undeclared variants, and perhaps not have ANY meaning. Again, w/o some indication of the larger picture it is QUITE difficult to see what is awry. For example, you noted that you have ~~ 20 other / additional constructs of this, but what is not clear is wheather you refere to 20 seperate If ... elseif ... end if blocks or one (rather large) If ... Else If ... Else If ... (and 18 more) ... End If. The latter would be a bit more challenging, but not very different in (correct) results. There is alos no indication of wheather the original (or any of the previous) conditionals are &quot;true&quot; prior to the one in question. Does any prior conditional trigger? If so, the remainder of the conditionals are not evaluated.

Another oddity, from the brevity of the posts, is that you note that this code is in the OnClose event? If so, what does making the controls visible do? They would, perhaps, flash visible momentarily, hten the form would close and they would be 'gone again'? Again, a more complete picture might easily reveal the answer, but the current status does not. Is this entire block of code within a 'with / end with' block? If so, perhaps the conreol references should include a &quot;.&quot; prefix?

There are numerous other 'issues' which remain murky, but this may serve to show why more is necessary to (reasonably) provide any assistance.




MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
The debug.print statements were to be placed in code, the 'debug window' is where i said the results will be printed. However, it will still work if they were placed in the debug window (you have access to the rs property values when in debug mode).
[tt]
I was simply using the following approach:
1. check what the values in the If-statement are, and
2. check if the ElseIf-statement is actually being
executed. It should skip the Else-If when the
<> condition is false.
3. If steps 1 and 2 are ok, then use a 'watch' to find
out where the values change state e.g. break when
A21.Visible state changes. Or perhaps just use an
Edit>Find in this case.

[/tt]
 
I copied and pasted the code as you requested. I ran the code. The only thing that happened was a box came up that said &quot;False&quot;. I caught about 1/4 of what you are talking about Michael so below is the code for this one form. Maybe that will help.

Option Compare Database

Private Sub Form_Close()
'Set all visible values to false
A1.Visible = False
A2.Visible = False
A3.Visible = False
A4.Visible = False
A5.Visible = False
A6.Visible = False
A7.Visible = False
A8.Visible = False
A9.Visible = False
A10.Visible = False
A11.Visible = False
A12.Visible = False
A13.Visible = False
A14.Visible = False
A15.Visible = False
A16.Visible = False
A17.Visible = False
A18.Visible = False
A19.Visible = False
A20.Visible = False
A21.Visible = False
A22.Visible = False
A23.Visible = False
A24.Visible = False
A25.Visible = False
A26.Visible = False
A27.Visible = False
A28.Visible = False
A29.Visible = False
A30.Visible = False
A31.Visible = False
A32.Visible = False
A33.Visible = False
E1.Visible = False
E2.Visible = False
E3.Visible = False
E4.Visible = False
E5.Visible = False
E6.Visible = False
E7.Visible = False
E8.Visible = False
E9.Visible = False
E10.Visible = False
E11.Visible = False
E12.Visible = False
E13.Visible = False
E14.Visible = False
E15.Visible = False
E16.Visible = False
E17.Visible = False
E18.Visible = False
E19.Visible = False
E20.Visible = False
E21.Visible = False
E22.Visible = False
E23.Visible = False
E24.Visible = False
E25.Visible = False
E26.Visible = False
E27.Visible = False
E28.Visible = False
E29.Visible = False
E30.Visible = False
E31.Visible = False
E32.Visible = False
E33.Visible = False
E34.Visible = False
E35.Visible = False
E36.Visible = False
E37.Visible = False
E38.Visible = False
E39.Visible = False
E40.Visible = False
E41.Visible = False
E42.Visible = False
E43.Visible = False
E44.Visible = False
E45.Visible = False
E46.Visible = False
E47.Visible = False
E48.Visible = False
E49.Visible = False
E50.Visible = False
E51.Visible = False
E53.Visible = False
E54.Visible = False
E55.Visible = False
E56.Visible = False
E57.Visible = False
E58.Visible = False
E59.Visible = False
Q2.Visible = False
Q3.Visible = False
Q4.Visible = False
Q5.Visible = False
Q6.Visible = False
Q7.Visible = False
Q8.Visible = False
BoxA1E50Q3.Visible = False
BoxA2E11E48Q6Q4.Visible = False
BoxA21E38E58.Visible = False
BoxA26.Visible = False
BoxA5A20.Visible = False
BoxA7Q5.Visible = False
BoxA9.Visible = False
BoxE13.Visible = False
BoxE14E37A19.Visible = False
BoxE25E1E25A6E52.Visible = False
BoxE26.Visible = False
BoxE51E39A17.Visible = False
BoxE9E10E34E35A4A14A18.Visible = False
BoxQ2A3A25.Visible = False
BoxQ7Q8A22.Visible = False
Line176.Visible = False
Line183.Visible = False
Line186.Visible = False
Line189.Visible = False
Line193.Visible = False
Line204.Visible = False
Line207.Visible = False
Line209.Visible = False
Line211.Visible = False
Line213.Visible = False
Line215.Visible = False
Line217.Visible = False
Line219.Visible = False
Line221.Visible = False
Line223.Visible = False
AnnBill.Visible = False
AnnCatBill.Visible = False
AnnEmpHrs.Visible = False
AnnIndEmpHrs.Visible = False
CumBill.Visible = False
CumBillSubDisc.Visible = False
CumEmpHrs.Visible = False
CumExp.Visible = False
CumExpNoMark.Visible = False
CumInd.Visible = False
CumNetPL.Visible = False
CumRev.Visible = False
MoBill.Visible = False
MoEmpHrs.Visible = False
MoIndEmpHrs.Visible = False
End Sub

Private Sub Label99_Click()
'If changes were made, this button does all the queries again.
Call Form_Open(True)
DoCmd.Requery
End Sub

Private Sub Form_Open(Cancel As Integer)
'Ask for yearly date, confirms date input is correct.
MsgBox &quot;Please answer date questions and wait for form to load. Thanks!&quot;
Dim CheckY
VarYN = 7
CheckY = Yes
Do While VarYN = 7
xYear = InputBox(&quot;Please enter a year (yyyy).&quot;, &quot;Enter Date&quot;, Date)
VarYN = MsgBox(&quot;You have entered &quot; & xYear & &quot;,&quot; & vbCrLf & &quot;Is this correct?&quot;, vbYesNo, &quot;Correct Date?&quot;)
If VarYN = 7 Then
CheckY = No
End If
Loop
Dim CheckM
VarYN = 7
CheckM = Yes
Do While VarYN = 7
'Ask for monthly date, confirms date input is correct.
xMonth = InputBox(&quot;Please enter a Month-Year (mm-yyyy).&quot;, &quot;Enter Date&quot;, Date)
VarYN = MsgBox(&quot;You have entered &quot; & xMonth & &quot;,&quot; & vbCrLf & &quot;Is this correct?&quot;, vbYesNo, &quot;Correct Date?&quot;)
If VarYN = 7 Then
CheckM = No
End If
Loop
'Opens each report needed, harvests the value, closes report.
DoCmd.OpenReport &quot;RPT-ARClientBillHistAnnual&quot;, acViewPreview 'Var1
Me.A1 = Var1
DoCmd.Close acReport, &quot;RPT-ARClientBillHistAnnual&quot;
DoCmd.OpenReport &quot;RPT-BillAvg&quot;, acViewPreview 'Var2
Me.A2 = Var2
DoCmd.Close acReport, &quot;RPT-BillAvg&quot;
DoCmd.OpenReport &quot;RPT-MoInvTotalbyMo&quot;, acViewPreview 'Var3
Me.A3 = Var3
DoCmd.Close acReport, &quot;RPT-MoInvTotalbyMo&quot;
DoCmd.OpenReport &quot;RPT-ProfitLoss&quot;, acViewPreview 'Var4
Me.A4 = Var4
DoCmd.Close acReport, &quot;RPT-ProfitLoss&quot;
DoCmd.OpenReport &quot;RPT-ProfitLossbyClass&quot;, acViewPreview 'Var5
Me.A5 = Var5
DoCmd.Close acReport, &quot;RPT-ProfitLossbyClass&quot;
DoCmd.OpenReport &quot;RPT-EmpHrsbyMo&quot;, acViewPreview 'Var6
Me.A6 = Var6
DoCmd.Close acReport, &quot;RPT-EmpHrsbyMo&quot;
DoCmd.OpenReport &quot;RPT-Cat&quot;, acViewPreview 'Var7
Me.A7 = Var7
DoCmd.Close acReport, &quot;RPT-Cat&quot;
DoCmd.OpenReport &quot;RPT-EmpHrsbyMo&quot;, acViewPreview 'Var8
Me.A8 = Var8
DoCmd.Close acReport, &quot;RPT-EmpHrsbyMo&quot;
DoCmd.OpenReport &quot;RPT-EmpHrsCumJPC&quot;, acViewPreview 'Var9
Me.A9 = Var9
DoCmd.Close acReport, &quot;RPT-EmpHrsCumJPC&quot;
DoCmd.OpenReport &quot;RPT-EmpHrsCumRDH&quot;, acViewPreview 'Var10
Me.A10 = Var10
DoCmd.Close acReport, &quot;RPT-EmpHrsCumRDH&quot;
DoCmd.OpenReport &quot;RPT-EmpHrsCumWKB&quot;, acViewPreview 'Var11
Me.A11 = Var11
DoCmd.Close acReport, &quot;RPT-EmpHrsCumWKB&quot;
DoCmd.OpenReport &quot;RPT-EmpHrsCumJAB&quot;, acViewPreview 'Var12
Me.A12 = Var12
DoCmd.Close acReport, &quot;RPT-EmpHrsCumJAB&quot;
DoCmd.OpenReport &quot;RPT-EmpHrsCumCMT&quot;, acViewPreview 'Var13
Me.A13 = Var13
DoCmd.Close acReport, &quot;RPT-EmpHrsCumCMT&quot;
DoCmd.OpenReport &quot;RPT-ProfitLossbyClass&quot;, acViewPreview 'Var14
Me.A14 = Var14
DoCmd.Close acReport, &quot;RPT-ProfitLossbyClass&quot;
DoCmd.OpenReport &quot;RPT-EmpHrsCum&quot;, acViewPreview 'Var15
Me.A15 = Var15
DoCmd.Close acReport, &quot;RPT-EmpHrsCum&quot;
DoCmd.OpenReport &quot;RPT-EmpHrsCumJLD&quot;, acViewPreview 'Var16
Me.A16 = Var16
DoCmd.Close acReport, &quot;RPT-EmpHrsCumJLD&quot;
DoCmd.OpenReport &quot;RPT-EmpHrsCum&quot;, acViewPreview 'Var17
Me.A17 = Var17
DoCmd.Close acReport, &quot;RPT-EmpHrsCum&quot;
DoCmd.OpenReport &quot;RPT-ProfitLossbyBillType&quot;, acViewPreview 'Var18
Me.A18 = Var18
DoCmd.Close acReport, &quot;RPT-ProfitLossbyBillType&quot;
DoCmd.OpenReport &quot;RPT-ProfitLoss&quot;, acViewPreview 'Var19
Me.A19 = Var19
DoCmd.Close acReport, &quot;RPT-ProfitLoss&quot;
DoCmd.OpenReport &quot;RPT-ProfitLossbyBillType&quot;, acViewPreview 'Var20
Me.A20 = Var20
DoCmd.Close acReport, &quot;RPT-ProfitLossbyBillType&quot;
DoCmd.OpenReport &quot;RPT-ProfitLoss&quot;, acViewPreview 'Var21
Me.A21 = Var21
DoCmd.Close acReport, &quot;RPT-ProfitLoss&quot;
DoCmd.OpenReport &quot;RPT-MoInvTotalbyMo&quot;, acViewPreview 'Var22
Me.A22 = Var22
DoCmd.Close acReport, &quot;RPT-MoInvTotalbyMo&quot;
DoCmd.OpenReport &quot;RPT-ProjectHrs&quot;, acViewPreview 'Var23
Me.A23 = Var23
DoCmd.Close acReport, &quot;RPT-ProjectHrs&quot;
DoCmd.OpenReport &quot;RPT-EmpHrsCumOLD&quot;, acViewPreview 'Var24
Me.A24 = Var24
DoCmd.Close acReport, &quot;RPT-EmpHrsCumOLD&quot;
DoCmd.OpenReport &quot;RPT-ARClientsBillHistCum&quot;, acViewPreview 'Var25
Me.A25 = Var25
DoCmd.Close acReport, &quot;RPT-ARClientsBillHistCum&quot;
DoCmd.OpenReport &quot;RPT-EmpHrsAnnualJPC&quot;, acViewPreview 'Var26
Me.A26 = Var26
DoCmd.Close acReport, &quot;RPT-EmpHrsAnnualJPC&quot;
DoCmd.OpenReport &quot;RPT-EmpHrsAnnualRDH&quot;, acViewPreview 'Var27
Me.A27 = Var27
DoCmd.Close acReport, &quot;RPT-EmpHrsAnnualRDH&quot;
DoCmd.OpenReport &quot;RPT-EmpHrsAnnualWKB&quot;, acViewPreview 'Var28
Me.A28 = Var28
DoCmd.Close acReport, &quot;RPT-EmpHrsAnnualWKB&quot;
DoCmd.OpenReport &quot;RPT-EmpHrsAnnualJAB&quot;, acViewPreview 'Var29
Me.A29 = Var29
DoCmd.Close acReport, &quot;RPT-EmpHrsAnnualJAB&quot;
DoCmd.OpenReport &quot;RPT-EmpHrsAnnualCMT&quot;, acViewPreview 'Var30
Me.A30 = Var30
DoCmd.Close acReport, &quot;RPT-EmpHrsAnnualCMT&quot;
DoCmd.OpenReport &quot;RPT-EmpHrsAnnual&quot;, acViewPreview 'Var31
Me.A31 = Var31
DoCmd.Close acReport, &quot;RPT-EmpHrsAnnual&quot;
DoCmd.OpenReport &quot;RPT-EmpHrsAnnualJLD&quot;, acViewPreview 'Var32
Me.A32 = Var32
DoCmd.Close acReport, &quot;RPT-EmpHrsAnnualJLD&quot;
DoCmd.OpenReport &quot;RPT-EmpHrsAnnualOLD&quot;, acViewPreview 'Var33
Me.A33 = Var33
DoCmd.Close acReport, &quot;RPT-EmpHrsAnnualOLD&quot;
'Temp code provided by Dan.
Debug.Print &quot;[A21]=&quot; & [A21]
Debug.Print &quot;[E38]=&quot; & [E38]
Debug.Print &quot;[E58]=&quot; & [E58]
Debug.Print &quot;Is This Statement True ([A21]=[E38]+[E58]): &quot; & [A21] = [E38] + [E58]
MsgBox &quot;Debug - Evaluate Expression (Equals): &quot; & [A21] = ([E38] + [E58])
'Evaluates all numbers under a double check system for financials.
A21.Visible = IIf(([A21] <> ([E38] + [B38])), &quot;True&quot;, &quot;False&quot;)
A21.Visible = E38.Visible
A21.Visible = B38.Visible
A21.Visible = CumNetPL.Visible
A21.Visible = Line221.Visible
A21.Visible = BoxA21E38E58.Visible
If (([A1] <> [E50]) Or ([A1] <> [Q3])) Then
A1.Visible = True
E50.Visible = True
Q3.Visible = True
AnnBill.Visible = True
Line176.Visible = True
BoxA1E50Q3.Visible = True
ElseIf ([Q5] <> [A7]) Then
A7.Visible = True
Q5.Visible = True
Line183.Visible = True
AnnCatBill.Visible = True
BoxA7Q5.Visible = True
ElseIf (([E39] <> [E51]) Or ([E39] <> [A17])) Then
E51.Visible = True
E39.Visible = True
A17.Visible = True
AnnEmpHrs.Visible = True
Line186.Visible = True
BoxE51E39A17.Visible = True
ElseIf ((([E9] + [E10]) <> ([E34] + [E35])) Or (([E9] + [E10]) <> [A4]) Or (([E9] + [E10]) <> [A14]) Or (([E9] + [E10]) <> [A18])) Then
E9.Visible = True
E10.Visible = True
E34.Visible = True
E35.Visible = True
A4.Visible = True
A14.Visible = True
A18.Visible = True
CumRev.Visible = True
Line189.Visible = True
BoxE9E10E34E35A4A14A18.Visible = True
ElseIf ((([E26] + [E27] + [E28] + [E29] + [E30] + [E31] + [E32] + [E33]) <> ([E2] + [E3] + [E4] + [E5] + [E6] + [E7] + [E8])) Or (([E26] + [E27] + [E28] + [E29] + [E30] + [E31] + [E32] + [E33]) <> ([E53] + [E54] + [E55] + [E56] + [E57] + [E59] + [E36]))) Then
E26.Visible = True
E27.Visible = True
E28.Visible = True
E29.Visible = True
E30.Visible = True
E31.Visible = True
E32.Visible = True
E33.Visible = True
E2.Visible = True
E3.Visible = True
E4.Visible = True
E5.Visible = True
E6.Visible = True
E7.Visible = True
E8.Visible = True
E53.Visible = True
E54.Visible = True
E55.Visible = True
E56.Visible = True
E57.Visible = True
E59.Visible = True
E36.Visible = True
Line217.Visible = True
MoIndEmpHrs.Visible = True
BoxE26.Visible = True
CumEmpHrs.Visible = True
ElseIf (([Q2] <> [A3]) Or ([Q2] <> [A25])) Then
Q2.Visible = True
A3.Visible = True
A25.Visible = True
CumBillSubDisc.Visible = True
Line204.Visible = True
BoxQ2A3A25.Visible = True
ElseIf (([A2] <> [E11]) Or ([A2] <> [E48]) Or ([A2] <> [Q6]) Or ([A2] <> ([Q4] - 2055))) Then
A2.Visible = True
E11.Visible = True
E48.Visible = True
Q6.Visible = True
Q4.Visible = True
CumBill.Visible = True
Line209.Visible = True
BoxA2E11E48Q6Q4.Visible = True
ElseIf ((([A9] + [A10] + [A11] + [A12] + [A13] + [A15] + [A16] + [A24]) <> [A8]) Or ([A8] <> [E49]) Or ([A8] <> [E12]) Or ([A8] <> [A23])) Then
A9.Visible = True
A10.Visible = True
A11.Visible = True
A12.Visible = True
A13.Visible = True
A15.Visible = True
A16.Visible = True
A23.Visible = True
A24.Visible = True
A8.Visible = True
E12.Visible = True
E49.Visible = True
CumEmpHrs.Visible = True
Line207.Visible = True
BoxA9.Visible = True
ElseIf (([E14] + [E37]) <> [A19]) Then
E14.Visible = True
E37.Visible = True
A19.Visible = True
CumExp.Visible = True
Line211.Visible = True
BoxE14E37A19.Visible = True
ElseIf ([A5] <> [A20]) Then
A5.Visible = True
A20.Visible = True
CumExpNoMark.Visible = True
Line219.Visible = True
BoxA5A20.Visible = True
ElseIf (([E23] <> ([E15] + [E16] + [E17] + [E18] + [E19] + [E20] + [E21] + [E22] + [E13])) Or ([E23] <> ([E13] + [E24]))) Then
E23.Visible = True
E15.Visible = True
E16.Visible = True
E17.Visible = True
E18.Visible = True
E19.Visible = True
E20.Visible = True
E21.Visible = True
E22.Visible = True
E13.Visible = True
E24.Visible = True
CumInd.Visible = True
Line213.Visible = True
BoxE13.Visible = True
'ElseIf (([A21] <> ([E38] + [E58]))) Then
' A21.Visible = True
' E38.Visible = True
' E58.Visible = True
'CumNetPL.Visible = True
' Line221.Visible = True
' BoxA21E38E58.Visible = True
ElseIf (([Q7] <> [Q8]) Or ([Q9] <> [A22])) Then
Q7.Visible = True
Q8.Visible = True
A22.Visible = True
MoBill.Visible = True
Line223.Visible = True
BoxQ7Q8A22.Visible = True
ElseIf (([E25] <> [E1]) Or ([E25] <> [A6]) Or ([E25] <> [E52])) Then
E25.Visible = True
E1.Visible = True
A6.Visible = True
E25.Visible = True
MoEmpHrs.Visible = True
Line215.Visible = True
BoxE25E1E25A6E52.Visible = True
ElseIf (([A26] + [A27] + [A28] + [A29] + [A30] + [A31] + [A32] + [A33]) <> ([E40] + [E41] + [E42] + [E43] + [E44] + [E45] + [E46] + [E47])) Then
A26.Visible = True
A27.Visible = True
A28.Visible = True
A29.Visible = True
A30.Visible = True
A31.Visible = True
A32.Visible = True
A33.Visible = True
E40.Visible = True
E41.Visible = True
E42.Visible = True
E43.Visible = True
E44.Visible = True
E45.Visible = True
E46.Visible = True
E47.Visible = True
AnnIndEmpHrs.Visible = True
Line193.Visible = True
BoxA26.Visible = True
Else: Box226.Visible = True
End If
End Sub

I hope this clarifies things more Michael.
Dan, the false is saying my numbers do not add up. So how can I tell what it is trying to add?

Thank you both for your help. JL
 
janetlyn,

I reviewed (and slightly restructured) your code, mostly for readability. I do not see any obvious issues in you construct. Things I looked at (to SOME level of detail):

Was the evaluated expression the same as any other expression evaluated later in the block;

Was the COMPLETE set of controls rendered &quot;.Visible&quot; addressed in another set whose properties were modified after the block;

Things I changed:

Restructured the ElseIf set to a series of independent If Statements (include a GoTo at the end of each block).

Replaced the long set of instructions which retrieve the &quot;VarN variables with an array of report names and a loop.

Replaced some (several) literal constants (7) with the &quot;intrinsic&quot; vbNo.

Added quite a bit of white space which I believe adds 'readability' to the code.

Replaced the 'groups' of setting controls.Visible to false on an individual basis with simple loops (e.g for &quot;A1&quot; to &quot;A33&quot; as well as E and Q.

Moved Dan's added code to inside the Block If in Question. This will &quot;post&quot; the variable values ONLY if the block is actually executed, which is another &quot;clue&quot; to the problem.

Added variable declarations for &quot;MyMsg&quot; and &quot;MyTitle&quot; and replaced some message box literals with these (just to make the physical line length shorter).

Added &quot;continuation&quot; characters for some expressions to shorten the physical line length and, perhaps, make the logic of the expression(s) somewhat easier to read / understand.

I ASSUME that most all of the assignments refer to controls on the form (&quot;A&quot;NN[/i}&quot;, (&quot;E&quot;NN[/i}&quot;, (&quot;Q&quot;N[/i}&quot;, (&quot;Var&quot;NN[/i}&quot;, etc, as these are not declared in the code.

since this was done rapidly and w/o a form to assure the various transforms were 'accurate', there may be some issues with the details of the construction, so you might want to just use the below as a guide to making some changes, acording to what you find easier to read / understand / deal with.

For the actual issue here, it MIGHT help to see the results of the debug screen after running through the code (and Assuring the conditions are met. My 'best guess', at the moment is that there is some small difference in the values of the fields, as will often occur, particularly if the fuields are of different type or are calculated fields.

I added another &quot;Test&quot; block immediatly above the block in question to (also) print out a value if the expression is &quot;close&quot; to 0.


I will attempt to send the actual CODE in another post. The combined &quot;Stuuuuuuf&quot; keeps giving me an err!




MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
Code:
Option Compare Database
    'janetlyn Tek-Tips thread702-745627 (Ms. A. Forms)
Option Explicit
Private Sub Form_Close()

    'Set all visible values to false
    Idx = 1
    While Idx <= 33
        Me.Controls(&quot;A&quot; & Trim(Idx).Visible) = False
        Idx = Idx + 1
    Wend

    Idx = 1
    While Idx <= 59
        Me.Controls(&quot;E&quot; & Trim(Idx).Visible) = False
        Idx = Idx + 1
    Wend

    Idx = 1
    While Idx <= 8
        Me.Controls(&quot;Q&quot; & Trim(Idx).Visible) = False
        Idx = Idx + 1
    Wend

    BoxA1E50Q3.Visible = False
    BoxA2E11E48Q6Q4.Visible = False
    BoxA21E38E58.Visible = False
    BoxA26.Visible = False
    BoxA5A20.Visible = False
    BoxA7Q5.Visible = False
    BoxA9.Visible = False
    BoxE13.Visible = False
    BoxE14E37A19.Visible = False
    BoxE25E1E25A6E52.Visible = False
    BoxE26.Visible = False
    BoxE51E39A17.Visible = False
    BoxE9E10E34E35A4A14A18.Visible = False
    BoxQ2A3A25.Visible = False
    BoxQ7Q8A22.Visible = False

    Line176.Visible = False
    Line183.Visible = False
    Line186.Visible = False
    Line189.Visible = False
    Line193.Visible = False
    Line204.Visible = False
    Line207.Visible = False
    Line209.Visible = False
    Line211.Visible = False
    Line213.Visible = False
    Line215.Visible = False
    Line217.Visible = False
    Line219.Visible = False
    Line221.Visible = False
    Line223.Visible = False

    AnnBill.Visible = False
    AnnCatBill.Visible = False
    AnnEmpHrs.Visible = False
    AnnIndEmpHrs.Visible = False

    CumBill.Visible = False
    CumBillSubDisc.Visible = False
    CumEmpHrs.Visible = False
    CumExp.Visible = False
    CumExpNoMark.Visible = False
    CumInd.Visible = False
    CumNetPL.Visible = False
    CumRev.Visible = False

    MoBill.Visible = False
    MoEmpHrs.Visible = False
    MoIndEmpHrs.Visible = False
End Sub



MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
Code:
Private Sub Label99_Click()
    'If changes were made, this button does all the queries again.
    Call Form_Open(True)
    DoCmd.Requery
End Sub



MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
Code:
Private Sub Form_Open(Cancel As Integer)

    Dim MyMsg As String     'Added MLR
    Dim MyTitle As String   'Added MLR

    'Ask for yearly date, confirms date input is correct.
    MsgBox &quot;Please answer date questions and wait for form to load.  Thanks!&quot;

    Dim CheckY
    VarYN = vbNo
    CheckY = Yes

    Do While VarYN = vbNo   'Modified MLD

        xYear = InputBox(&quot;Please enter a year (yyyy).&quot;, &quot;Enter Date&quot;, Date)
        MyMsg = &quot;You have entered &quot; & xYear & &quot;,&quot; & vbCrLf & &quot;Is this correct?&quot;
        MyTitle = &quot;Correct Date?&quot;
        VarYN = MsgBox(MyMsg, vbYesNo, MyTitle)
        If VarYN = vbNo Then
            CheckY = No
        End If

    Loop

    Dim CheckM
    VarYN = vbNo
    CheckM = Yes

    Do While VarYN = vbNo   'Modified MLD

        'Ask for monthly date, confirms date input is correct.
        xMonth = InputBox(&quot;Please enter a Month-Year (mm-yyyy).&quot;, &quot;Enter Date&quot;, Date)
        MyMsg = &quot;You have entered &quot; & xMonth & &quot;,&quot; & vbCrLf & &quot;Is this correct?&quot;
        VarYN = MsgBox(MyMsg, vbYesNo, &quot;Correct Date?&quot;)

        If VarYN = vbNo Then
            CheckM = No
        End If

    Loop

    'Declarations, Assignments and Loop Added MLR. _
     To Replace the individual Groups of Instructions.
    Dim RptNames(40) As String
    RptNames(0) = &quot;&quot;
    RptNames(1) = &quot;RPT-ARClientBillHistAnnual&quot;
    RptNames(2) = &quot;RPT-BillAvg&quot;
    RptNames(3) = &quot;RPT-MoInvTotalbyMo&quot;
    RptNames(4) = &quot;RPT-ProfitLoss&quot;
    RptNames(5) = &quot;RPT-ProfitLossbyClass&quot;
    RptNames(6) = &quot;RPT-EmpHrsbyMo&quot;
    RptNames(7) = &quot;RPT-Cat&quot;&quot;&quot;
    RptNames(8) = &quot;RPT-EmpHrsbyMo&quot;
    RptNames(9) = &quot;RPT-EmpHrsCumJPC&quot;
    RptNames(10) = &quot;RPT-EmpHrsCumRDH&quot;
    RptNames(11) = &quot;RPT-EmpHrsCumWKB&quot;
    RptNames(12) = &quot;RPT-EmpHrsCumJAB&quot;
    RptNames(13) = &quot;RPT-EmpHrsCumCMT&quot;
    RptNames(14) = &quot;RPT-ProfitLossbyClass&quot;
    RptNames(15) = &quot;RPT-EmpHrsCum&quot;
    RptNames(16) = &quot;RPT-EmpHrsCumJLD&quot;
    RptNames(17) = &quot;RPT-EmpHrsCum&quot;
    RptNames(18) = &quot;RPT-ProfitLossbyBillType&quot;
    RptNames(19) = &quot;RPT-ProfitLoss&quot;
    RptNames(20) = &quot;RPT-ProfitLossbyBillType&quot;
    RptNames(21) = &quot;RPT-ProfitLoss&quot;
    RptNames(22) = &quot;RPT-ProjectHrsRPT-MoInvTotalbyMo&quot;
    RptNames(23) = &quot;RPT-ProjectHrs&quot;
    RptNames(24) = &quot;RPT-EmpHrsCumOLD&quot;
    RptNames(25) = &quot;RPT-ARClientsBillHistCum&quot;
    RptNames(26) = &quot;RPT-EmpHrsAnnualJPC&quot;
    RptNames(27) = &quot;RPT-EmpHrsAnnualRDH&quot;
    RptNames(28) = &quot;RPT-EmpHrsAnnualWKB&quot;
    RptNames(29) = &quot;RPT-EmpHrsAnnualJAB&quot;
    RptNames(30) = &quot;RPT-EmpHrsAnnualCMT&quot;
    RptNames(31) = &quot;RPT-EmpHrsAnnual&quot;
    RptNames(32) = &quot;RPT-EmpHrsAnnualJLD&quot;
    RptNames(33) = &quot;RPT-EmpHrsAnnualOLD&quot;
    RptNames(34) = &quot;&quot;
    RptNames(35) = &quot;&quot;
    RptNames(36) = &quot;&quot;
    RptNames(37) = &quot;&quot;
    RptNames(38) = &quot;&quot;
    RptNames(39) = &quot;&quot;

    'Opens each report needed, harvests the value, closes report.
    Dim Idx As Integer
    While Idx <= UBoound(RptNames)
        If (RptNames(Idx) = &quot;&quot;) Then
            DoCmd.OpenReport RptNames(Idx), acViewPreview 'Var1
            Me(&quot;A&quot; & Trim(Idx)) = Var & Trim(Idx)
            DoCmd.Close acReport, RptNames(Idx)
        End If
        Idx = Idx + 1
    Loop


This is JUST the TOP of the Form OPEN rouyine. Remainder (hopefully!) Follows





MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
Hopeing the rest will fit!

Code:
    'Evaluates  all numbers under a double check system for financials.
    A21.Visible = ([A21] <> ([E38] + [B38])) _
                  Or E38.Visible _
                  Or B38.Visible _
                  Or CumNetPL.Visible _
                  Or Line221.Visible _
                  Or BoxA21E38E58.Visible

    If (([A1] <> [E50]) Or ([A1] <> [Q3])) Then
        A1.Visible = True
        E50.Visible = True
        Q3.Visible = True
        AnnBill.Visible = True
        Line176.Visible = True
        BoxA1E50Q3.Visible = True
        GoTo CondFnd
    End If

    If ([Q5] <> [A7]) Then
        A7.Visible = True
        Q5.Visible = True
        Line183.Visible = True
        AnnCatBill.Visible = True
        BoxA7Q5.Visible = True
        CondFnd
    End If

    If (([E39] <> [E51]) Or ([E39] <> [A17])) Then
        E51.Visible = True
        E39.Visible = True
        A17.Visible = True
        AnnEmpHrs.Visible = True
        Line186.Visible = True
        BoxE51E39A17.Visible = True
        CondFnd
    End If

    If ((([E9] + [E10]) <> ([E34] + [E35])) _
          Or (([E9] + [E10]) <> [A4]) _
          Or (([E9] + [E10]) <> [A14]) _
          Or (([E9] + [E10]) <> [A18])) Then

        E9.Visible = True
        E10.Visible = True
        E34.Visible = True
        E35.Visible = True
        A4.Visible = True
        A14.Visible = True
        A18.Visible = True
        CumRev.Visible = True
        Line189.Visible = True
        BoxE9E10E34E35A4A14A18.Visible = True
        CondFnd
    End If

    If ((([E26] + [E27] + [E28] + [E29] _
            + [E30] + [E31] + [E32] + [E33]) _
            <> ([E2] + [E3] + [E4] + [E5] + [E6] + [E7] + [E8])) _
            Or (([E26] + [E27] + [E28] + [E29] _
            + [E30] + [E31] + [E32] + [E33]) _
            <> ([E53] + [E54] + [E55] + [E56] _
            + [E57] + [E59] + [E36]))) Then

        E26.Visible = True
        E27.Visible = True
        E28.Visible = True
        E29.Visible = True
        E30.Visible = True
        E31.Visible = True
        E32.Visible = True
        E33.Visible = True
        E2.Visible = True
        E3.Visible = True
        E4.Visible = True
        E5.Visible = True
        E6.Visible = True
        E7.Visible = True
        E8.Visible = True
        E53.Visible = True
        E54.Visible = True
        E55.Visible = True
        E56.Visible = True
        E57.Visible = True
        E59.Visible = True
        E36.Visible = True
        Line217.Visible = True
        MoIndEmpHrs.Visible = True
        BoxE26.Visible = True
        CumEmpHrs.Visible = True
        CondFnd
    End If

    If (([Q2] <> [A3]) Or ([Q2] <> [A25])) Then
        Q2.Visible = True
        A3.Visible = True
        A25.Visible = True
        CumBillSubDisc.Visible = True
        Line204.Visible = True
        BoxQ2A3A25.Visible = True
        CondFnd
    End If

    If (([A2] <> [E11]) _
          Or ([A2] <> [E48]) _
          Or ([A2] <> [Q6]) _
          Or ([A2] <> ([Q4] - 2055))) Then

        A2.Visible = True
        E11.Visible = True
        E48.Visible = True
        Q6.Visible = True
        Q4.Visible = True
        CumBill.Visible = True
        Line209.Visible = True
        BoxA2E11E48Q6Q4.Visible = True
        CondFnd
    End If

    If ((([A9] + [A10] + [A11] + [A12] + [A13] _
             + [A15] + [A16] + [A24]) <> [A8]) _
             Or ([A8] <> [E49]) _
             Or ([A8] <> [E12]) _
             Or ([A8] <> [A23])) Then

        A9.Visible = True
        A10.Visible = True
        A11.Visible = True
        A12.Visible = True
        A13.Visible = True
        A15.Visible = True
        A16.Visible = True
        A23.Visible = True
        A24.Visible = True
        A8.Visible = True
        E12.Visible = True
        E49.Visible = True
        CumEmpHrs.Visible = True
        Line207.Visible = True
        BoxA9.Visible = True
        CondFnd
    End If

    If (([E14] + [E37]) <> [A19]) Then
        E14.Visible = True
        E37.Visible = True
        A19.Visible = True
        CumExp.Visible = True
        Line211.Visible = True
        BoxE14E37A19.Visible = True
        CondFnd
    End If

    If ([A5] <> [A20]) Then
        A5.Visible = True
        A20.Visible = True
        CumExpNoMark.Visible = True
        Line219.Visible = True
        BoxA5A20.Visible = True
        CondFnd
    End If

    If (([E23] <> ([E15] + [E16] + [E17] + [E18] _
            + [E19] + [E20] + [E21] + [E22] + [E13])) _
            Or ([E23] <> ([E13] + [E24]))) Then

        E23.Visible = True
        E15.Visible = True
        E16.Visible = True
        E17.Visible = True
        E18.Visible = True
        E19.Visible = True
        E20.Visible = True
        E21.Visible = True
        E22.Visible = True
        E13.Visible = True
        E24.Visible = True
        CumInd.Visible = True
        Line213.Visible = True
        BoxE13.Visible = True
        CondFnd
    End If

    If (Abs([A21]) - Abs([E38] + [E58] <= 0.1)) Then
        Debug.Print &quot;At least it is close&quot; & vbCrLf & _
        &quot;[A21 = &quot; & [A21] & vbCrLf & _
        &quot;[E38] = &quot; & [E38] & vbCrLf & _
        &quot;[E58] = &quot; & [E58] & vbCrLf & _
        &quot;The difference is: &quot;; Abs([A21]) - Abs([E38] + [E58])
    End If

    If (([A21] <> ([E38] + [E58]))) Then

        'Temp code provided by Dan.
        Debug.Print &quot;[A21]=&quot; & [A21]
        Debug.Print &quot;[E38]=&quot; & [E38]
        Debug.Print &quot;[E58]=&quot; & [E58]
        Debug.Print &quot;Is This Statement True ([A21]=[E38]+[E58]): &quot; & [A21] = [E38] + [E58]
        MsgBox &quot;Debug - Evaluate Expression (Equals): &quot; & [A21] = ([E38] + [E58])

        A21.Visible = True
        E38.Visible = True
        E58.Visible = True
        CumNetPL.Visible = True
        Line221.Visible = True
        BoxA21E38E58.Visible = True
        CondFnd
    End If

    If (([Q7] <> [Q8]) Or ([Q9] <> [A22])) Then
        Q7.Visible = True
        Q8.Visible = True
        A22.Visible = True
        MoBill.Visible = True
        Line223.Visible = True
        BoxQ7Q8A22.Visible = True
        CondFnd
    End If

    If (([E25] <> [E1]) Or ([E25] <> [A6]) Or ([E25] <> [E52])) Then
        E25.Visible = True
        E1.Visible = True
        A6.Visible = True
        E25.Visible = True
        MoEmpHrs.Visible = True
        Line215.Visible = True
        BoxE25E1E25A6E52.Visible = True
        GoTo CondFnd
    End If

    If (([A26] + [A27] + [A28] + [A29] + [A30] _
            + [A31] + [A32] + [A33]) _
            <> ([E40] + [E41] + [E42] + [E43] _
            + [E44] + [E45] + [E46] + [E47])) Then

        A26.Visible = True
        A27.Visible = True
        A28.Visible = True
        A29.Visible = True
        A30.Visible = True
        A31.Visible = True
        A32.Visible = True
        A33.Visible = True
        E40.Visible = True
        E41.Visible = True
        E42.Visible = True
        E43.Visible = True
        E44.Visible = True
        E45.Visible = True
        E46.Visible = True
        E47.Visible = True
        AnnIndEmpHrs.Visible = True
        Line193.Visible = True
        BoxA26.Visible = True
     Else
        Box226.Visible = True

    End If

CondFnd:

End Sub

Sorry this arrives SO late, but the page keeps giving me errs.
[/code]

When/If arrived, I'm done for the time.




MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
Thank you so much Michael. Please do not take this the wrong way. I copied my database, deleted my code, inserted your code. I felt like you wrote code with little errors in there for me to figure out. To some degree it was fun and I was quite surprised how many problems I (think) I fixed. However, now I am to an error I cannot resolve. It looks fine to me but the computer does not like it and I cannot determine why. I know you said you were taking the rest of the day off (good for you) so if I don't hear from you for awhile, no problem. Here is the message it gives me:

The Action or Method requires a Report Name Argument.

The code it does not like:

DoCmd.OpenReport RptNames(Idx), acViewPreview 'Var1

Here are the lines surrounding the code:

Dim Idx As Integer
Dim Var As Integer 'Added because 4 lines down it wants &quot;Var&quot; defined.
Do While Idx <= UBound(RptNames)
If (RptNames(Idx) = &quot;&quot;) Then
DoCmd.OpenReport RptNames(Idx), acViewPreview 'Var1
Me(&quot;A&quot; & Trim(Idx)) = Var & Trim(Idx)
DoCmd.Close acReport, RptNames(Idx)
End If
Idx = Idx + 1
Loop


I would appreciate any help you can give. Thanks, JL
 
If (RptNames(Idx) = &quot;&quot;) Then


[tabSHOULD be


If (RptNames(Idx) <> &quot;&quot;) Then

Sorry for the confusion.




MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
Michael, okay, fixed that.

Up above (wayyyyyy up above) is this same error. Now I am getting it in your code, exactly where it was in my code. I do not understand.

&quot;Run time error 2465: Project Database can't find the field '|' referred to in your expression.&quot;

Here is the code it highlights in yellow:

A21.Visible = ([A21] <> ([E38] + [B38])) _
Or E38.Visible _
Or [B38].Visible _
Or CumNetPL.Visible _
Or Line221.Visible _
Or BoxA21E38E58.Visible

Note it is the same ElseIf statement I have had trouble with since the beginning.

I do not know what the | is referring to. Any suggestions? JL
 
The &quot;\&quot; is Chr(124), often / usually refered to as the &quot;Pipe&quot; character. It is the symbol used to denote a one of many (set) selection. It is not (directly) found in the specific code statement, so I can only &quot;surmise that it is somehow involved as a reference in one (or more) field or variables.

There DOES appear to be an ERROR in the line:

[tab][tab]Or [B38].Visible _


which should (apparently) refer to a CONTROL B38,
form not the recordsource FIELD [B38].

This should -in itself be an error, since a field does not have a &quot;.Visible&quot; porperty, but it should not return the error you describe.

Since the error refers to the &quot;Field&quot;, I would start with another set of debug statements (immediatly preceeding the statement) to print the field values. If those are ok, see &quot;ControlType&quot; (the ubiquitous {F1} -a.k.a. Help) and assure that the various controls are not somehow 'incorrect' and actually have a &quot;.Visible&quot; property. Finally, in the original form, the statement was broken into seperate (individual) assignments, which SPECIFIC statement was highlighted there? Was it the &quot;IF&quot; or one of the others? The one which was originally highlighted includes the &quot;invalid&quot; reference, so your investigation needs to focus on the members (fields and controls referenced) on that specific line.

In short, I haven't a clue to the specifics, and can only suggest generic trouble shooting / debug practices.

One last thought, for the 'suspect' elements, try changing them to another (valid?) control or field (as appropiate) and placing a &quot;breakpoint&quot; ([b[F9[/b] on the statement. For each field, just place the cursor (mouse pointer) over the field when highlighted. The &quot;value&quot; indicated in the cursor pop-up window is what the program 'thinks; it is using. If any are the pipe char. this is at least the real soource of the error. How to fix it is another dialog.

You can do much the same in the immediate (debug) window. When the error (or breakpoint) occurs, in the immediate window, type:

? A21.Visible
? [A21]
? [E38]
? [B38]
? E38.Visible
? [B38].Visible[tab][tab] or is it &quot;? B38&quot; ???????
? CumNetPL.Visible
? Line221.Visible
? BoxA21E38E58.Visible

Actually, you can just copy the above to your debug window and place the cursor at the beginning of the first line and hit the <Cr> until you get past he last one. Immediatly below the individual lines, the status will be displayed (the VALUE of the fields, True or False for the controls). To see the content of umNetPL, just delete the &quot;.Visible&quot;.







MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
Jumping in to address an issue that has yet to be discussed, there is a problem with the following statement:
Code:
If (([A1] <> [E50]) Or ([A1] <> [Q3])) Then
Provided that E50 <> Q3, this statement will always return true. It is a common mistake, but this should be an AND conditional. If A1 = E50, then A1 cannot = Q3, and so the second part will be true. If A1 = Q3, then A1 cannot be = E50 so the first part will be true. So either one or the other will always be true, so ORing them together will always be true. The proper statement should read
Code:
If (([A1] <> [E50]) And ([A1] <> [Q3])) Then

Compound negative conditionals should be ANDed together and you do this several times during this long IF-ELSEIF statement.

With respect to the run-time error, what are the values of A21, E38 and B38. Also, what is, if any, the value of the ControlSource for these three, I assume, textboxes?

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Michael, debugging is like rocket science to me right now. However, I think you gave me enough data to complete the job. If I don't answer back immediately, don't fret, I will. I appreciate all your help.

CajunCenturion:

Since the A1 number comes from a report in Access, the E50 comes from inputted data linked to an Excel spreadsheet, and the same for Q50, it has to be OR. All three numbers are supposed to be the same. That is why I cannot figure out why I am getting a false because my addition is correct. (The false information is a reference from above and recommended by Dan.) Unfortunately, he has not come back to tell me what to do after I have received the False, to tell how to determine why it is false.

But, I think from the debugging techniques mentioned by Michael above, I can now determine what values it is really getting.

If after reading this you do not agree about the AND/OR situation please comment back. Thanks for everyone's help, JL
 
Where the numbers come from really has no bearing on how they should be logically compared, but perhaps I misunderstand you intentions. Do you want the block of code to be executed if they are all the same, or if they are not all the same?

To execute if not all the same, then you need to And them together. Consider the following:
A1 = 100
E50 = 100
Q50 = 101
Code:
If (([A1] <> [E50]) Or ([A1] <> [Q3])) Then
    (100  <>  100)  Or (100  <> 101) 
         False      Or      True       ==>   True
Using OR would be correct if you want the THEN clause to be executed if they are NOT all the same.

On the other hand, if it is your intention to insure that all three numbers are the same, then I suggest using the following conditional, which, to me at least, is much easier to understand.
Code:
If ((A1 = E50) And (A1 = Q3)) Then
   ' They are all the same
Else
   ' They are not all the same
End If

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
I will have to think about that. I will be honest and admit I am the most unlogical woman you will ever meet. That said, this is a form with 59 numbers gathered from Access reports and an Excel spreadsheet. These numbers are being compared to each other to make sure they match. So I actually have about 10 groups whose numbers must all match. When the form is opened it is blank except for a finished button. If all the numbers match they can click finish and go on their merry way. However, if a group of the numbers are not the same, such as A1, E50, or Q3, then Those three numbers appear with a note of where they were garnered so the person can go find their input error and then rerun the queries again, checking the matches. So all numbers are the same, else it displays said numbers.

Right now, on the textboxes in the form the Visible property is set to False. When the formula is executed, if True (a number does not match a number in the group), that group becomes visible and the program stops. Once all the groups have been verified and they are all good numbers, the person closes the form. On_Close makes sure all the groups, lines, messages, etc. are all set to false, although I should probably not need this code.


As for your last example, I believe that is what I have done; only it is for 59 textboxes (10 groups of numbers), i.e. a bunch of If...ElseIf...Then code. The first reallllly long purple box of this thread (starts off with a bunch of xxxx.Visible=False, is my actual code. Michael has made it more efficient, although I am not sure how his code works completely. The problem is finding that '|' character the code does not like. The rest works fine.

Your views and ideas are appreciated because it gives me food for thought on improving my code (database). Thanks Cajun, JL
 
Just to Throw another monkey into the wrench:

Code:
Public Function basCompareMultiValsEqual(ParamArray MyVals() As Variant) As Boolean

    Dim MyVal As Variant
    Dim Idx As Integer

    MyVal = MyVals(0)

    While Idx <= UBound(MyVals)

        If (MyVals(Idx) <> MyVal) Then
            Return
        End If

        Idx = Idx + 1
    Wend

    basCompareMultiValsEqual = True

End Function

Is, perhaps, a bit less ambigious, as illustrated by the following:

Code:
Public Function basTstMultiEqu()

    'Sample Usage _
    ? basTstMultiEqu
    'True

    Dim MyAry(2) As Single
    Dim MyTest As Boolean

    MyAry(0) = 123.456
    MyAry(1) = 123456 / 1000
    MyAry(2) = 12.3456 * 10

    MyTest = basCompareMultiValsEqual(MyAry(0), MyAry(1), MyAry(2))
    Debug.Print MyTest

End Function
Of course it can be used to find inequality just by reversing the returned value, or variations on the theme appear (un-bidden) in memory just thinking it through.





MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
:-D MichaelRed, I was thinking about the same thing, writing a simple function with a ParamArray to compare the elements.

MichaelRed - Side question, totally unrelated to the thread, but I've noticed that you seem to prefer While loops to For loops, even for known iteration counts. Any particular reason?

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
hmmmmmmmmmmmmmmmmm ... mmmmmmmmmmm,

A couple of &quot;issues&quot; in that bag:

First There is the simple mental laziness. I REALLY, REALLLY like the option explicit. But usiing the For Each w/o a declared variable leaves the loop control w/ a (possibly) un-declared item as well as the question of wheather to use just &quot;Next&quot; or &quot;Next CtrlVar. In simple cases, there is not much difference -except the lesser thinking, as hte While ALWAYS requires the declaration of the control variable and you ALWAYS need to increment it.

Second, there have been persistient 'rumoors' the MS would simplify (e.g. eliminate some as they can ALL be used to accomplish most any / all looping. The 'programmer' just needs to be aware of where to place the various checks for terminiation conditions and control variable updates. Mostly, in this context, the bits and pieces I have seen refered to 'loosing' the &quot;For-Next&quot; constructions.




MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top