This one really has me puzzled. Normally I know how to deal with this type of error, but this time it is defying all my troubleshooting knowledge.
I have a query def (qryCustomerCre ditScore). In my VBA code, I'm opening a recordset based on this query that sums some of the fields, counts another one, and then performs a custom function based on the last one. It is when I open this recordset that I get the Too few parameters error. So, as I normally do, I set a breakpoint and then used the immediate window to pull my SQL string from the VBA, copied and pasted it into a query def and then ran it. No error was returned. However, no records were returned. So I decided to run qryCustomerCred itScore(I'm still in Break mode) and it didn't return any records either. I then stopped my code and re-ran qryCustomerCred itScoreand it now returns records. So I run my query def based on my VBA SQL string and it works fine. I try to run it again through the code and it errors out again. While still in break mode I run qryCustomerCred itScoreand no records are returned.
I have never seen this or read about it online. Normally I would say that I got a field name typed incorrectly, but that doesn't seem to be the case this time since it all works fine when not being ran through code. I don't know if this matters, but my tables are stored on SQL Server connected through ODBC drivers (DSN-less connection).
Here is the code for qryCustomerCred itScore:
Here is the VBA code up to the line that errors out (line 18):
The strCust string concatenates out to
I can't think of any other details that would be necessary, but like I said, I don't know what to look at right now. If I have missed something, just ask and I will provide it.
I have a query def (qryCustomerCre ditScore). In my VBA code, I'm opening a recordset based on this query that sums some of the fields, counts another one, and then performs a custom function based on the last one. It is when I open this recordset that I get the Too few parameters error. So, as I normally do, I set a breakpoint and then used the immediate window to pull my SQL string from the VBA, copied and pasted it into a query def and then ran it. No error was returned. However, no records were returned. So I decided to run qryCustomerCred itScore(I'm still in Break mode) and it didn't return any records either. I then stopped my code and re-ran qryCustomerCred itScoreand it now returns records. So I run my query def based on my VBA SQL string and it works fine. I try to run it again through the code and it errors out again. While still in break mode I run qryCustomerCred itScoreand no records are returned.
I have never seen this or read about it online. Normally I would say that I got a field name typed incorrectly, but that doesn't seem to be the case this time since it all works fine when not being ran through code. I don't know if this matters, but my tables are stored on SQL Server connected through ODBC drivers (DSN-less connection).
Here is the code for qryCustomerCred itScore:
Code:
SELECT CustID_pk , QuoteID_fk , GetIndividualCS([CustID_pk]) AS CreditScore , CustFN , CustLN , Income , CollNum , CollAmt , ITIN FROM tblCustomers WHERE QuoteID_fk=[Forms]![frmConsumerMortgageCalculator]![QuoteID]
Code:
Private Sub SetValues() On Error GoTo Error_Handler Dim db As DAO.Database Dim strQuote As String Dim rstQuote As DAO.Recordset Dim strCust As String Dim rstCust As DAO.Recordset Set db = CurrentDb strQuote = "SELECT * FROM tblQuotes WHERE QuoteID = " & lngQuoteID Set rstQuote = db.OpenRecordset(strQuote, dbOpenDynaset, dbSeeChanges) strCust = "SELECT QuoteID_fk, Sum(Income) AS LnIncome, Sum(CollNum) AS LnCollNum, " & _ "Sum(CollAmt) AS LnCollAmt, Count(ITIN) AS IsITIN, GetLoanCS([QuoteID_fk]) AS CreditScore " & _ "FROM qryCustomerCreditScore GROUP BY QuoteID_fk" Set rstCust = db.OpenRecordset(strCust, dbOpenDynaset, dbSeeChanges)
Code:
SELECT QuoteID_fk , Sum(Income) AS LnIncome , Sum(CollNum) AS LnCollNum , Sum(CollAmt) AS LnCollAmt , Count(ITIN) AS IsITIN , GetLoanCS([QuoteID_fk]) AS CreditScore FROM qryCustomerCreditScore GROUP BY QuoteID_fk
Comment