VB error #3061: too few parameters. expected 9 (1 Viewer)

palomiko

New member
Local time
Today, 03:00
Joined
Oct 24, 2011
Messages
2
Hi,

I need help. When I click on 'Run" this error window appears: "error #3061: too few parameters. expected 9"

Here is code:

Option Compare Database
Option Explicit

Sub Import_SDC()

Dim cas
cas = Timer

RunSql "Kme"
RunSql "KonMat"
RunSql "Psku"
RunSql "SkuPar"
RunSql "Skl"
RunSql "Subj"
RunSql "TpUct"
RunSql "Dodl"
RunSql "Dodla"
RunSql "APS_SEGM"
Update_DIS

CurrentDb.Execute "UPDATE SDC_Subj AS a SET a.Subj_APS = subj_aps(a.SUBJ_ID)"

CurrentDb.Execute "UPDATE SDC_Subj AS s SET s.KUKLA = 3 WHERE s.ndis='06'"

DoCmd.Echo True, "Ready"
DoCmd.Hourglass False
MsgBox "Èas : " & Format(Timer - cas, "MM:SS"), vbInformation, "Èas Access"

End Sub

Sub RunSql(sTbl$)
Dim rs As Recordset, i%, m1$, m2$, sSQL As String

CurrentDb.Execute "DELETE FROM SDC_" & sTbl$

Set rs = CurrentDb.OpenRecordset("SDC_" & sTbl)
m1 = ""
m2 = ""
For i = 0 To rs.Fields.Count - 1
m1 = m1 & rs.Fields(i).Name & ", "
m2 = m2 & "a.Pole" & i + 1 & ", "
Next
sSQL = "INSERT INTO SDC_" & sTbl$ & " ( " & Left(m1, Len(m1) - 2) & " ) SELECT " & Left(m2, Len(m2) - 2) & " FROM S_" & sTbl$ & " AS a"
CurrentDb.Execute sSQL

End Sub

Sub Update_DIS()
CurrentDb.Execute "UPDATE SDC_Subj AS a SET a.DIS = 'OT'"
CurrentDb.Execute "UPDATE (SDC_Subj AS a INNER JOIN CRM_Obce AS c ON a.OBEC_KOD = c.OBEC_KOD) INNER JOIN Vkbur AS s ON c.cit_region = s.cit_region SET a.DIS = .[dis];"
' CurrentDb.Execute "UPDATE SDC_Subj AS s INNER JOIN Vkbur AS v ON s.DIS = v.DIS SET s.NDIS = [v].[ndis];"
End Sub

Public Function SUBJ_APS(saps As Variant) As Variant
If saps > 10000000000000# Then saps = saps - 9900000000000#
SUBJ_APS = saps
End Function




Can somebody help me with this.

Thanks a lot in advance
 

JamesMcS

Keyboard-Chair Interface
Local time
Today, 11:00
Joined
Sep 7, 2009
Messages
1,819
What line does it error on?
 

palomiko

New member
Local time
Today, 03:00
Joined
Oct 24, 2011
Messages
2
line: CurrentDb.Execute sSQL
 

JamesMcS

Keyboard-Chair Interface
Local time
Today, 11:00
Joined
Sep 7, 2009
Messages
1,819
I would do a debug.print on all those variables and see what's in them. First thing I saw that would error out is the len(m2)... expressions - if m2's length is zero, and you subtract 2, the left function will produce an error.
 

MSAccessRookie

AWF VIP
Local time
Today, 06:00
Joined
May 2, 2008
Messages
3,428
line: CurrentDb.Execute sSQL

Take a look at the content of the variable sSQL at the time of execution, and show us what it is. You might just see something wrong that will steer you toward the solution.
 

Users who are viewing this thread

Top Bottom