tc3596
Technical User
- Mar 16, 2001
- 283
Here is my sub...
Public Sub CompileReport()
Dim PrintFlag As Boolean
Dim OnChange$, OpenAmount As Double
Dim DateFlag As Boolean, InvoiceNo$
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Call CreateTemp
Set AccessDb = OpenDatabase(ReportPath$ & "oeslscom.mdb")
Set OESLSCOM = AccessDb.OpenRecordset("OESLSCOM", dbOpenTable)
PrintFlag = False
If txtSalesNo1 = "All" Then
SalesmanNo1$ = "000"
SalesmanNo2$ = "zzz"
Else
SalesmanNo1$ = txtSalesNo1
SalesmanNo2$ = txtSalesNo2
End If
DocumentDate1$ = ConvertDateTime(txtInvoiceDate1, "DS")
DocumentDate2$ = ConvertDateTime(txtInvoiceDate2, "DS")
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
KEY_ARO$ = Space$(255)
AroStatus = BTRCALL(BGETFIRST, AROPNFIL$, REC_ARO, BUF_ARO, ByVal KEY_ARO$, KEY_LEN, 1)
Do Until AroStatus <> 0
If OnChange$ <> REC_ARO.AR_OPN_CUS_NO & REC_ARO.AR_OPN_APPLY_TO Then
OpenAmount = 0
InvoiceNo$ = ""
DateFlag = False
OnChange$ = REC_ARO.AR_OPN_CUS_NO & REC_ARO.AR_OPN_APPLY_TO
End If
OpenAmount = OpenAmount + (Comp3ToVariant(REC_ARO.AR_OPN_AMT1, 8, 2) + Comp3ToVariant(REC_ARO.AR_OPN_AMT2, 8, 2))
OpenAmount = Format$(OpenAmount, "0.00")
If (REC_ARO.AR_OPN_DOC_TP = "C" Or REC_ARO.AR_OPN_DOC_TP = "P") Then
If REC_ARO.AR_OPN_DOC_DT >= DocumentDate1$ And REC_ARO.AR_OPN_DOC_DT <= DocumentDate2$ Then
DateFlag = True
End If
End If
txtStatus = KEY_ARO$
DoEvents
AroStatus = BTRCALL(BGETNEXT, AROPNFIL$, REC_ARO, BUF_ARO, ByVal KEY_ARO$, KEY_LEN, 1)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
If AroStatus <> 0 Or OnChange$ <> REC_ARO.AR_OPN_CUS_NO & REC_ARO.AR_OPN_APPLY_TO Then
If DateFlag And OpenAmount = 0 Then
KEY_ARO$ = OnChange$ & Space$(100)
AroStatus = BTRCALL(BGETGREATEROREQUAL, AROPNFIL$, REC_ARO, BUF_ARO, ByVal KEY_ARO$, KEY_LEN, 1)
Do Until AroStatus <> 0 Or Mid$(KEY_ARO$, 1, 20) > OnChange$
InvoiceNo$ = ""
If REC_ARO.AR_OPN_DOC_TP = "I" Then InvoiceNo$ = REC_ARO.AR_OPN_DOC_NO
If REC_ARO.AR_OPN_DOC_TP = "C" Then InvoiceNo$ = REC_ARO.AR_OPN_DOC_NO
Call WriteToTemp(InvoiceNo$, 1)
AroStatus = BTRCALL(BGETNEXT, AROPNFIL$, REC_ARO, BUF_ARO, ByVal KEY_ARO$, KEY_LEN, 1)
Loop
End If
End If
Loop
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
End Sub
I was wondering if anyone could translate this for me....
AROPNFIL is the table
REC_ARO appears to be the recordset
I am thinking of creating an ADODB recordset...and looping thruough. I am confused about all the GetNext and BGETGREATEROREQUAL calls in the middle of the loop. How is it sorting the data?
Thanks for your help.
Public Sub CompileReport()
Dim PrintFlag As Boolean
Dim OnChange$, OpenAmount As Double
Dim DateFlag As Boolean, InvoiceNo$
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Call CreateTemp
Set AccessDb = OpenDatabase(ReportPath$ & "oeslscom.mdb")
Set OESLSCOM = AccessDb.OpenRecordset("OESLSCOM", dbOpenTable)
PrintFlag = False
If txtSalesNo1 = "All" Then
SalesmanNo1$ = "000"
SalesmanNo2$ = "zzz"
Else
SalesmanNo1$ = txtSalesNo1
SalesmanNo2$ = txtSalesNo2
End If
DocumentDate1$ = ConvertDateTime(txtInvoiceDate1, "DS")
DocumentDate2$ = ConvertDateTime(txtInvoiceDate2, "DS")
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
KEY_ARO$ = Space$(255)
AroStatus = BTRCALL(BGETFIRST, AROPNFIL$, REC_ARO, BUF_ARO, ByVal KEY_ARO$, KEY_LEN, 1)
Do Until AroStatus <> 0
If OnChange$ <> REC_ARO.AR_OPN_CUS_NO & REC_ARO.AR_OPN_APPLY_TO Then
OpenAmount = 0
InvoiceNo$ = ""
DateFlag = False
OnChange$ = REC_ARO.AR_OPN_CUS_NO & REC_ARO.AR_OPN_APPLY_TO
End If
OpenAmount = OpenAmount + (Comp3ToVariant(REC_ARO.AR_OPN_AMT1, 8, 2) + Comp3ToVariant(REC_ARO.AR_OPN_AMT2, 8, 2))
OpenAmount = Format$(OpenAmount, "0.00")
If (REC_ARO.AR_OPN_DOC_TP = "C" Or REC_ARO.AR_OPN_DOC_TP = "P") Then
If REC_ARO.AR_OPN_DOC_DT >= DocumentDate1$ And REC_ARO.AR_OPN_DOC_DT <= DocumentDate2$ Then
DateFlag = True
End If
End If
txtStatus = KEY_ARO$
DoEvents
AroStatus = BTRCALL(BGETNEXT, AROPNFIL$, REC_ARO, BUF_ARO, ByVal KEY_ARO$, KEY_LEN, 1)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
If AroStatus <> 0 Or OnChange$ <> REC_ARO.AR_OPN_CUS_NO & REC_ARO.AR_OPN_APPLY_TO Then
If DateFlag And OpenAmount = 0 Then
KEY_ARO$ = OnChange$ & Space$(100)
AroStatus = BTRCALL(BGETGREATEROREQUAL, AROPNFIL$, REC_ARO, BUF_ARO, ByVal KEY_ARO$, KEY_LEN, 1)
Do Until AroStatus <> 0 Or Mid$(KEY_ARO$, 1, 20) > OnChange$
InvoiceNo$ = ""
If REC_ARO.AR_OPN_DOC_TP = "I" Then InvoiceNo$ = REC_ARO.AR_OPN_DOC_NO
If REC_ARO.AR_OPN_DOC_TP = "C" Then InvoiceNo$ = REC_ARO.AR_OPN_DOC_NO
Call WriteToTemp(InvoiceNo$, 1)
AroStatus = BTRCALL(BGETNEXT, AROPNFIL$, REC_ARO, BUF_ARO, ByVal KEY_ARO$, KEY_LEN, 1)
Loop
End If
End If
Loop
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
End Sub
I was wondering if anyone could translate this for me....
AROPNFIL is the table
REC_ARO appears to be the recordset
I am thinking of creating an ADODB recordset...and looping thruough. I am confused about all the GetNext and BGETGREATEROREQUAL calls in the middle of the loop. How is it sorting the data?
Thanks for your help.