Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: What an Array.


Message #1 by "Gamble, Shawn" <Shawn_Gamble@S...> on Fri, 6 Oct 2000 13:41:14 -0500
Nope I'm not sure the array is being initialized correctly but all I want to
do is limit the records returned by placing a where clause in the SQL Here's
the bulk of the proceedure.
SORRY FOR THE LENGTH LIST. Like I said changing the sql causes and out of
script range error. Needless to say at this point I am studing up on arrays

****************************************************************************
********
    Call ViewQd
    GblQdView.SQL = "SELECT * FROM CINVOICE WHERE CREATION_DATE BETWEEN '" &
Format(FromDate, "yyyy-mm-dd hh:nn:ss") & "' AND '" & Format(ToDate,
"yyyy-mm-dd hh:nn:ss") & " '" 
    Set RsInvAudit = GblQdView.OpenRecordset()
    GblQdView.Close
    Set GblQdView = Nothing    
    i = 1
    Do Until RsInvAudit.EOF
        AuditArray.ReDim 1, i, 0, 7
        AuditArray(i, 0) = RsInvAudit!CINVOICE_NUMBER.Value
        
        If RsInvAudit!cinvoice_status = "VOID" Then
            AuditArray(i, 1) = "VOID"
            AuditArray(i, 2) = "VOID"
        Else
            Call ViewQd
            GblQdView.SQL = "SELECT NAME FROM COMPANY WHERE COMPANY_NUMBER 
" & RsInvAudit!company_number.Value & ""
            Set RsCompany = GblQdView.OpenRecordset()
            GblQdView.Close
            Set GblQdView = Nothing
            AuditArray(i, 1) = RsCompany!name.Value
            RsCompany.Close
            Set RsCompany = Nothing
            
            Call ViewQd
            GblQdView.SQL = "SELECT NAME FROM COMPANY WHERE COMPANY_NUMBER 
" & RsInvAudit!Req_Company_Number.Value & ""
            Set RsCompany = GblQdView.OpenRecordset()
            GblQdView.Close
            Set GblQdView = Nothing
            AuditArray(i, 2) = RsCompany!name.Value
            RsCompany.Close
            Set RsCompany = Nothing
        End If
        
        AuditArray(i, 3) = RsInvAudit!Shipped_Date.Value
        AuditArray(i, 4) = RsInvAudit!SHIPMENT_METHOD.Value
        
        Call ViewQd
        GblQdView.SQL = "SELECT QUANTITY, COST, EXCHANGE_RATE,
MARKUP_PERCENT FROM CINV_DETAIL WHERE CINVOICE_NUMBER = " &
RsInvAudit!CINVOICE_NUMBER & " and Company_number = '" & Text1.Text & "'"
        Set RsInvCost = GblQdView.OpenRecordset()
        GblQdView.Close
        Set GblQdView = Nothing

        Do Until RsInvCost.EOF
            StrCst = Format(((RsInvCost!cost * RsInvCost!exchange_rate) / (1
- RsInvCost!markup_percent / 100)), "#####0.0000")
            If Right(StrCst, 2) > 0 Then
                DblCst = Format(StrCst + 0.01, "#####0.00")
            Else
                DblCst = Format(StrCst, "#####0.00")
            End If
            AuditArray(i, 5) = AuditArray(i, 5) + (RsInvCost!quantity *
DblCst)
            RsInvCost.MoveNext
        Loop        
        RsInvCost.Close
        Set RsInvCost = Nothing
        
        Call ViewQd
        GblQdView.SQL = "SELECT SUM(AMOUNT) AS INV_AMT FROM CINV_COSTS WHERE
CINVOICE_NUMBER = " & RsInvAudit!CINVOICE_NUMBER & ""
        Set RsInvCost = GblQdView.OpenRecordset()
        GblQdView.Close
        Set GblQdView = Nothing

        If RsInvCost.RecordCount > 0 Then
            AuditArray(i, 6) = AuditArray(i, 6) + RsInvCost!Inv_Amt.Value
        End If
        
        RsInvCost.Close
        Set RsInvCost = Nothing
        
        AuditArray(i, 6) = RsInvAudit!Description.Value
        If Len(AuditArray(i, 3)) = 0 Then
            AuditArray(i, 6) = "Y"
        End If
        RsInvAudit.MoveNext
        i = i + 1
    Loop
    RsInvAudit.Close
    Set RsInvAudit = Nothing
    
    StrSQL = "SELECT * FROM INVRPT ;"
    Set RsInvRpt = GblDbODBC.OpenRecordset(StrSQL, dbOpenDynaset,
dbAppendOnly)
    
    For i = 1 To AuditArray.UpperBound(1)
        RsInvRpt.AddNew
        With RsInvRpt
            !CINVOICE_NUMBER = AuditArray(i, 0)
            !Req_Co = AuditArray(i, 2)
            If Len(AuditArray(i, 1)) > 0 Then
                !Pur_Co = AuditArray(i, 1)
            End If
            If Len(AuditArray(i, 3)) > 0 Then
                !Shipped_Date = AuditArray(i, 3)
            End If
            If Len(AuditArray(i, 4)) > 0 Then
                !SHIPMENT_METHOD = AuditArray(i, 4)
            End If
            If Len(AuditArray(i, 5)) > 0 Then
                !Inv_Amt = AuditArray(i, 5)
            End If
            If Len(AuditArray(i, 6)) > 0 Then
                !Description = AuditArray(i, 6)
            End If
            !Open_Sw = AuditArray(i, 7)
        End With
        RsInvRpt.Update
    Next
    RsInvRpt.Close

-----Original Message-----
From: Pawlikowski, Romuald
[mailto:Romuald.Pawlikowski@d...]
Sent: Wednesday, October 11, 2000 1:16 AM
To: professional vb
Subject: [pro_vb] RE: What an Array.


Hi Shawn,

I haven't done much with crystal reports, so excuse my ignorance on this
topic, you use this AuditArray and I guess it's either your own object or
crystal reports. 

Are you sure that you properly initialized the array? There's no code on
this in your sample. (I mean it should be big enough to contain all your
data and the size should be specified before you start putting anything in
it.)

Somewhere in your code (or in the AuditArray) there should be:

Dim MyArray([the number of rows in your array], 8) as string

Maybe I am talking about obvious thing but I hope it might prove useful.

Romek

  Return to Index