Solved

Tuff counter question

Posted on 2004-03-24
3
145 Views
Last Modified: 2010-05-01
This code is not working right. In the section which will test to see:
What is will do is pull 6 names and four will print on page on and 2 on the 2nd.
The mod statement is what is used to toggle between pg1 and pg2.
What I need it to do is print to 2 copies for each of the 4 name on page one and 2 copies for per name on the 2nd. So that will give me  8 copies of pg1 and 4 copies of pg2.
Total = 12 pages. If I had 3 name on page 2 then it would give me 6 of that page.
What I’m missing is some sort of counter for how many pages need to print for page one and page two. Now it will print = number of page 1 and page 2.
Please help
If UBound(temp_array) < 9 Then ‘(which it is =6 in this case)
          If (index Mod 2 = 0) Then
               oRequest.SetValue "right_1”, "to", temp_array(5)
Here is the actual code section I’m using:

For Index = 1 To Val(print_count)
     If UBound(temp_array) < 5 Then
          oRequest.SetValue "right_1", "to", temp_array(1)
          If UBound(temp_array) >= 2 Then
               oRequest.SetValue "right_2", "to", temp_array(2)
          Else
               oRequest.SetValue "right_2", "to", ""
          End If
          If UBound(temp_array) >= 3 Then
               oRequest.SetValue "right_3", "to", temp_array(3)
          Else
               oRequest.SetValue "right_3", "to", ""
          End If
          If UBound(temp_array) >= 4 Then
               oRequest.SetValue "right_4", "to", temp_array(4)
          Else
               oRequest.SetValue "right_4", "to", ""
          End If
     Else
        If UBound(temp_array) < 9 Then
          If (Index Mod 2 = 0) Then
               oRequest.SetValue "right_1", "to", temp_array(5)
               If UBound(temp_array) >= 6 Then
                    oRequest.SetValue "right_2", "to", temp_array(6)
               Else
                    oRequest.SetValue "right_2", "to", ""
               End If
               If UBound(temp_array) >= 7 Then
                    oRequest.SetValue "right_3", "to", temp_array(7)
               Else
                    oRequest.SetValue "right_3", "to", ""
               End If
               If UBound(temp_array) >= 8 Then
                    oRequest.SetValue "right_4", "to", temp_array(8)
               Else
                    oRequest.SetValue "right_4", "to", ""
               End If
          Else
               oRequest.SetValue "right_1", "to", temp_array(1)
               If UBound(temp_array) >= 2 Then
                    oRequest.SetValue "right_2", "to", temp_array(2)
               Else
                    oRequest.SetValue "right_2", "to", ""
               End If
               If UBound(temp_array) >= 3 Then
                    oRequest.SetValue "right_3", "to", temp_array(3)
               Else
                    oRequest.SetValue "right_3", "to", ""
               End If
               If UBound(temp_array) >= 4 Then
                    oRequest.SetValue "right_4", "to", temp_array(4)
               Else
                    oRequest.SetValue "right_4", "to", ""
               End If
          End If
       Else
         If UBound(temp_array) < 13 Then
               Let pg3_count = pg3_count + 1
               If Val(pg3_count) = 1 Then
                 Let nd_pg3 = 1
               End If
               If Val(pg3_count) = 2 Then
                 Let nd_pg3 = 5
               End If
               If Val(pg3_count) = 3 Then
                 Let nd_pg3 = 9
                 Let pg3_count = 0
               End If
               Let nbr = nd_pg3
               oRequest.SetValue "right_1", "to", temp_array(nbr)
               Let nbr = Val(nbr) + 1
               If UBound(temp_array) >= Val(nbr) Then
                    oRequest.SetValue "right_2", "to", temp_array(nbr)
               Else
                    oRequest.SetValue "right_2", "to", ""
               End If
               Let nbr = Val(nbr) + 1
               If UBound(temp_array) >= Val(nbr) Then
                    oRequest.SetValue "right_3", "to", temp_array(nbr)
               Else
                    oRequest.SetValue "right_3", "to", ""
               End If
               Let nbr = Val(nbr) + 1
               If UBound(temp_array) >= Val(nbr) Then
                    oRequest.SetValue "right_4", "to", temp_array(nbr)
               Else
                    oRequest.SetValue "right_4", "to", ""
               End If

0
Comment
Question by:cdb424ttm
  • 2
3 Comments
 
LVL 6

Accepted Solution

by:
___XXX_X_XXX___ earned 500 total points
ID: 10672254
Is this:
oRequest.SetValue "right_1", "to", temp_array(1)
Changes temp_array of some kind ?

I can't understand well your question.

Also I can't see corresponding "Next Index" for "For Index=...."

And your If...Then...Else statements can be optimized and code will be more readable.

0
 

Author Comment

by:cdb424ttm
ID: 10672314

Here is the whole chuck of code that I'm using.

Dim Temp_Array()
Dim index
Dim counter
Dim print_count
Dim stgBorr
Dim stgWaiver
Dim lend_count
Dim nd_pg3
Dim pg3_count
Dim nd_pg4
Dim pg4_count
Dim nbr
Dim pg1Borr
Dim home_count

      '----------------------------------------------
oRequest.SetValue "Right_to_Home" , "to" ,
"False"
home_count = 0

For index = 1 To Val( CDE.LT-BORROWER.BORR-NAME("Count") )
     If CDE.LT-BORROWER.RT-RESCIND(index) = True Then
          counter = counter + 1
     End If
Next
'(new defect   add homestead if prop-type = 1  2-15-02
If Val(CDE.LT-MASTER.PROP-TYPE) = 1 Then
   For index = 1 To Val( CDE.LT-BORROWER.BORR-NAME("Count") )
     If CDE.LT-BORROWER.RT-RESCIND(index) = True Then
        If CDE.LT-BORROWER.HOMESTD-WAIVER-NAME(index) <> ""
Then
          counter = counter + 1
          home_count = home_count + 1
        End If
     End If
   Next
End If
   
   If Val(home_count) <> 0 Then
      oRequest.SetValue "Right_to_Home" , "to" ,
"True"
   End If

If Val(counter) <> 0 Then
   If Val(counter) > 12 Then
      Let lend_count = 4
   Else
      If Val(counter) > 8 And Val(counter) <= 12 Then
         Let lend_count = 3
      Else
         If Val(counter) > 4 And Val(counter) <= 8 Then
            Let lend_count = 2
         Else
            Let lend_count = 1
         End If
      End If
   End If
       
   Let print_count = (Val(counter) * 2) + Val(lend_count)

ReDim Temp_Array(counter)
counter = 0
For index = 1 To Val( CDE.LT-BORROWER.BORR-NAME("Count") )
     If CDE.LT-BORROWER.RT-RESCIND(index) = True Then
          counter = counter + 1
          stgBorr = CDE.LT-BORROWER.BORR-NAME(index)
          If Val(counter) = 1 Then
             Let pg1Borr = stgBorr
          Else
             Let pg1Borr = pg1Borr & ", " & stgBorr
          End If
          If CDE.LT-BORROWER.POA-FLAG(index) = True Then
             stgBorr = stgBorr & vbnewline & "By: " &
CDE.LT-BORROWER.POA-NAME(index)
          End If
          Temp_Array(counter) = stgBorr
     End If
Next
'(new defect   add homestead if prop-type = 1  2-15-02
If Val(CDE.LT-MASTER.PROP-TYPE) = 1 Then
   For index = 1 To Val( CDE.LT-BORROWER.BORR-NAME("Count") )
     If CDE.LT-BORROWER.RT-RESCIND(index) = True Then
        If CDE.LT-BORROWER.HOMESTD-WAIVER-NAME(index) <> ""
Then
          counter = counter + 1
          stgWaiver = CDE.LT-BORROWER.HOMESTD-WAIVER-NAME(index) &
"*"
          Let pg1Borr = pg1Borr & ", " & stgWaiver
          Temp_Array(counter) = stgWaiver
        End If
     End If
   Next
End If


For index = 1 To Val(print_count)
     If UBound(temp_array) < 5 Then
          oRequest.SetValue "right_1" , "to", temp_array(1)
          If UBound(temp_array) >= 2 Then
               oRequest.SetValue "right_2" , "to",
temp_array(2)
          Else
               oRequest.SetValue "right_2" , "to",
""
          End If
          If UBound(temp_array) >= 3 Then
               oRequest.SetValue "right_3" , "to",
temp_array(3)
          Else
               oRequest.SetValue "right_3" , "to",
""
          End If
          If UBound(temp_array) >= 4 Then
               oRequest.SetValue "right_4" , "to",
temp_array(4)
          Else
               oRequest.SetValue "right_4" , "to",
""
          End If
     Else
        If UBound(temp_array) < 9 Then
          If  (index Mod 2 = 0) Then
               oRequest.SetValue "right_1" , "to",
temp_array(5)
               If UBound(temp_array) >= 6 Then
                    oRequest.SetValue "right_2" , "to",
temp_array(6)
               Else
                    oRequest.SetValue "right_2" , "to",
""
               End If
               If UBound(temp_array) >= 7 Then
                    oRequest.SetValue "right_3" , "to",
temp_array(7)
               Else
                    oRequest.SetValue "right_3" , "to",
""
               End If
               If UBound(temp_array) >= 8 Then
                    oRequest.SetValue "right_4" , "to",
temp_array(8)
               Else
                    oRequest.SetValue "right_4" , "to",
""
               End If
          Else
               oRequest.SetValue "right_1" , "to",
temp_array(1)
               If UBound(temp_array) >= 2 Then
                    oRequest.SetValue "right_2" , "to",
temp_array(2)
               Else
                    oRequest.SetValue "right_2" , "to",
""
               End If
               If UBound(temp_array) >= 3 Then
                    oRequest.SetValue "right_3" , "to",
temp_array(3)
               Else
                    oRequest.SetValue "right_3" , "to",
""
               End If
               If UBound(temp_array) >= 4 Then
                    oRequest.SetValue "right_4" , "to",
temp_array(4)
               Else
                    oRequest.SetValue "right_4" , "to",
""
               End If
          End If
       Else
         If UBound(temp_array) < 13 Then
               Let pg3_count = pg3_count + 1
               If Val(pg3_count) = 1 Then
                 Let nd_pg3 = 1
               End If
               If Val(pg3_count) = 2 Then
                 Let nd_pg3 = 5
               End If
               If Val(pg3_count) = 3 Then
                 Let nd_pg3 = 9
                 Let pg3_count = 0
               End If
               Let nbr = nd_pg3
               oRequest.SetValue "right_1" , "to",
temp_array(nbr)
               Let nbr = Val(nbr) + 1
               If UBound(temp_array) >= Val(nbr) Then
                    oRequest.SetValue "right_2" , "to",
temp_array(nbr)
               Else
                    oRequest.SetValue "right_2" , "to",
""
               End If
               Let nbr = Val(nbr) + 1
               If UBound(temp_array) >= Val(nbr) Then
                    oRequest.SetValue "right_3" , "to",
temp_array(nbr)
               Else
                    oRequest.SetValue "right_3" , "to",
""
               End If
               Let nbr = Val(nbr) + 1
               If UBound(temp_array) >= Val(nbr) Then
                    oRequest.SetValue "right_4" , "to",
temp_array(nbr)
               Else
                    oRequest.SetValue "right_4" , "to",
""
               End If
         Else
            If UBound(temp_array) < 17 Then
               Let pg4_count = pg4_count + 1
               If Val(pg4_count) = 1 Then
                 Let nd_pg4 = 1
               End If
               If Val(pg4_count) = 2 Then
                 Let nd_pg4 = 5
               End If
               If Val(pg4_count) = 3 Then
                 Let nd_pg4 = 9
               End If
               If Val(pg4_count) = 4 Then
                 Let nd_pg4 = 13
                 Let pg4_count = 0
               End If
               Let nbr = nd_pg4
               oRequest.SetValue "right_1" , "to",
temp_array(nbr)
               Let nbr = Val(nbr) + 1
               If UBound(temp_array) >= Val(nbr) Then
                    oRequest.SetValue "right_2" , "to",
temp_array(nbr)
               Else
                    oRequest.SetValue "right_2" , "to",
""
               End If
               Let nbr = Val(nbr) + 1
               If UBound(temp_array) >= Val(nbr) Then
                    oRequest.SetValue "right_3" , "to",
temp_array(nbr)
               Else
                    oRequest.SetValue "right_3" , "to",
""
               End If
               Let nbr = Val(nbr) + 1
               If UBound(temp_array) >= Val(nbr) Then
                    oRequest.SetValue "right_4" , "to",
temp_array(nbr)
               Else
                    oRequest.SetValue "right_4" , "to",
""
               End If
 
            End If
         
         End If
       End If
     End If
     oRequest.SetValue "acrosspage" , "to" , 1
     oRequest.SetValue "pg1numborr" , "to" , 4
     oRequest.SetValue "Right_to_Borr" , "to" , pg1Borr
If Val(CDE.LT-MASTER.PROP-TYPE) = 1 Then
     oRequest.SetValue "sigline_vars" , "to" ,
"0,0,0,1,1,0,0"
Else
     oRequest.SetValue "sigline_vars" , "to" ,
"0,0,0,0,1,0,0"
            End If
            oTemplate.LoadFormData
            oForm.NoOfCopies = -1
            oForm.RelativePosition = 5
            oForm.Setcopy "File"
            AddFormToPackage
      Next
      
      
      
End If
0
 

Author Comment

by:cdb424ttm
ID: 10680360
no one can seem to help me with this go ahead and delete question.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now