TesseractE
New Member
- Joined
- Nov 30, 2011
- Messages
- 38
(Access 2010)
I'm getting 'Too Few Parameters: Expected 1' from VB. Usually, when I'm trying to get OpenRecordset to work in VB and it fails due to 'Too Few Parameters', I have a debug.print spit out the SQL String, plug the string into a Query and get a better, more precise error message to work with. Not this time, though. The output works perfectly fine in SQL View.
I've checked a few suggestions I found on other resources and some issues with this that I've resolved in the past...
I can't post all of the code or any of my DBs, as some of it's confidential info, but I can share the script that's generating the issue:
And the "Debug.Print SQLString" resolves in this case to:
The purpose of this is to take the list of a QM's Skills that are stored as strings (TempVars!tv_QMLive & TempVars!tv_QMTraining) and find the Representatives ('Reps') that they would be qualified to handle (Rep Skills are listed in [Live Regions] & [Training Regions]). We also want to only bring up Reps who've had fewer audits than their target (A_TotalAudits.Audits < [Agent Master].[Current Target]) and who've NOT been selected within the last 6 hours (Int((Now()-[Last Click])*1440)>359)).
Any suggestions?
I'm getting 'Too Few Parameters: Expected 1' from VB. Usually, when I'm trying to get OpenRecordset to work in VB and it fails due to 'Too Few Parameters', I have a debug.print spit out the SQL String, plug the string into a Query and get a better, more precise error message to work with. Not this time, though. The output works perfectly fine in SQL View.
I've checked a few suggestions I found on other resources and some issues with this that I've resolved in the past...
- The 'A_TotalAudits' Query's working just fine
- It doesn't look like any of the field names are Reserved.
- The only fields that are accepting strings from VB are 'Text', and are being fed text values, so it shouldn't be a type mismatch.
- It's not referring to any fields on Forms or TempVars (So no QueryDefs should be needed)
- Option Compare Database, Option Explicit at the top of the Form Object
I can't post all of the code or any of my DBs, as some of it's confidential info, but I can share the script that's generating the issue:
Code:
QMSkills = Split(TempVars!tv_QMLive & TempVars!tv_QMTraining, "-")
Do Until x = UBound(QMSkills)
If SearchString = "" Then
SearchString = "(InStr(1,[Live Regions] & [Training Regions],'" & QMSkills(x) & "-')>0)"
Else
SearchString = SearchString & " or (InStr(1,[Live Regions] & [Training Regions],'" & QMSkills(x) & "-')>0)"
End If
x = x + 1
Loop
Debug.Print Len(SearchString)
x = 0
If SearchString = "" Then Exit Sub
SQLString = "SELECT [Agent Master].[Rep Name], [Agent Master].Site, [Agent Master].[Indigo ID], [Agent Master].[Agent Comments], [Agent Master].ACD, [Agent Master].[LAN ID], [Agent Master].EXT, [Agent Master].System, [Agent Master].[Fidelity ID], [Agent Master].Manager, [Agent Master].[2nd Level Mgr], [Agent Master].[Delta Comments], [Agent Master].[Delta Change Date], [Agent Master].[Delta End Date], [Agent Master].[Current Target], [Agent Master].[Live Regions], [Agent Master].[Training Regions], [Agent Master].[Last Click], A_TotalAudits.Audits " & _
"FROM [Agent Master] INNER JOIN A_TotalAudits ON [Agent Master].[Rep Name] = A_TotalAudits.[Rep Name] " & _
"WHERE ((" & SearchString & ") and (A_TotalAudits.Audits < [Agent Master].[Current Target]) and (Int((Now()-[Last Click])*1440)>359)) " & _
"ORDER BY A_TotalAudits.Audits, [Agent Master].[Indigo ID]; "
Debug.Print SQLString
Set AM = DB.OpenRecordset(SQLString)
And the "Debug.Print SQLString" resolves in this case to:
Code:
SELECT [Agent Master].[Rep Name], [Agent Master].Site, [Agent Master].[Indigo ID], [Agent Master].[Agent Comments], [Agent Master].ACD, [Agent Master].[LAN ID], [Agent Master].EXT, [Agent Master].System, [Agent Master].[Fidelity ID], [Agent Master].Manager, [Agent Master].[2nd Level Mgr], [Agent Master].[Delta Comments], [Agent Master].[Delta Change Date], [Agent Master].[Delta End Date], [Agent Master].[Current Target], [Agent Master].[Live Regions], [Agent Master].[Training Regions], [Agent Master].[Last Click], A_TotalAudits.Audits FROM [Agent Master] INNER JOIN A_TotalAudits ON [Agent Master].[Rep Name] = A_TotalAudits.[Rep Name] WHERE (((InStr(1,[Live Regions] & [Training Regions],'[COL]-')>0) or (InStr(1,[Live Regions] & [Training Regions],'[LIQ]-')>0) or (InStr(1,[Live Regions] & [Training Regions],'[HPS]-')>0) or (InStr(1,[Live Regions] & [Training Regions],'[BK]-')>0) or (InStr(1,[Live Regions] & [Training Regions],'[MED]-')>0) or (InStr(1,[Live Regions] & [Training Regions],'[DRAC]-')>0) or (InStr(
1,[Live Regions] & [Training Regions],'[CCRG]-')>0) or (InStr(1,[Live Regions] & [Training Regions],'[LIT]-')>0)) and (A_TotalAudits.Audits < [Agent Master].[Current Target]) and (Int((Now()-[Last Click])*1440)>359)) ORDER BY A_TotalAudits.Audits, [Agent Master].[Indigo ID];
The purpose of this is to take the list of a QM's Skills that are stored as strings (TempVars!tv_QMLive & TempVars!tv_QMTraining) and find the Representatives ('Reps') that they would be qualified to handle (Rep Skills are listed in [Live Regions] & [Training Regions]). We also want to only bring up Reps who've had fewer audits than their target (A_TotalAudits.Audits < [Agent Master].[Current Target]) and who've NOT been selected within the last 6 hours (Int((Now()-[Last Click])*1440)>359)).
Any suggestions?