jordanking
Programmer
- Sep 8, 2005
- 351
Hello
I am trying to capture the values of a recordset's field that is nested inside a loop. I am doing this becasue I need to speed up the procedure (currently 6.5 min). I am working with Access 2003.
here is what i am trying (truncated version)
the error returned is a "type mismatch".
so if I chagne my declaration to:
the error returned is "object required"
Is there another
I am trying to capture the values of a recordset's field that is nested inside a loop. I am doing this becasue I need to speed up the procedure (currently 6.5 min). I am working with Access 2003.
here is what i am trying (truncated version)
Code:
Dim rstNumInv As New ADODB.Recordset
Dim lADBCusID As Field
Dim sqlNumInv As String
sqlNumInv = "SELECT tblSales.lngzCustomer AS AccessID, tblCustomer.numInvoiceType, tblCompany.txtName, tblCompany.txtBranch, tblCustomer.txtLastName, tblCustomer.txtFirstName, tblCustomer.lngSDBID AS SdbID, tblCustomer.lngzAccountStatus FROM tblCompany RIGHT JOIN (tblCustomer RIGHT JOIN tblSales ON tblCustomer.idsCustomerID = tblSales.lngzCustomer) ON tblCompany.idsCompanyID = tblCustomer.lngzCompanyID GROUP BY tblSales.lngzCustomer, tblCustomer.numInvoiceType, tblCompany.txtName, tblCompany.txtBranch, tblCustomer.txtLastName, tblCustomer.txtFirstName, tblCustomer.lngSDBID, tblCustomer.lngzAccountStatus HAVING ((Not (tblSales.lngzCustomer) = 5192) And ((tblCustomer.numInvoiceType) = 1) And ((tblCustomer.lngzAccountStatus) < 3)) ORDER BY tblCompany.txtName, tblCompany.txtBranch, tblCustomer.txtLastName, tblCustomer.txtFirstName;"
rstNumInv.Open sqlNumInv, CurrentProject.Connection, adOpenStatic, adLockReadOnly
Set lADBCusID = rstNumInv.Fields("AccessID")
for i = 1 to 380
if rstNumInv.EOF = False then
''run this code that uses lADBCusID
end if
next
the error returned is a "type mismatch".
so if I chagne my declaration to:
Code:
Set lADBCusID = rstNumInv.Fields("AccessID").Value
the error returned is "object required"
Is there another