I am using Access 2013. When I run a macro, I get this error
Run-time error ‘3061’
Too few parameters. Expected 1.
If I open the debug window, I see the code below. The line in bold is highlighted by the debugger.
Can anyone give me some guidance on how to troubleshoot this? To make thinks even more fun, I am new to Access, or any database application, am not a developer, and did not write the macro that is failing. But I do need get the macro working again, so any ideas that you may have on how to resolve this would be appreciated. Thanks in advance for any assistance on this problem.
Option Compare Database
Public Sub GetMISLManual()
dbdFields = Array(“P0210”, “P0310”, “P0410”, “P0510”, “P0610”, “P0710”, “P0810”, “P0910”, “P1010”, “P1110”)
SQLFields = Array(“FEB”, “MAR”, “APR”, “MAY”, “JUN”, “JUL”, “AUG”, “SEP”, “OCT”, “NOV”, “DEC”, “JAN”)
‘dbdFields = Array(“P1210”)
‘SQLFields = Array(“DEC”)
‘NETSALES=8, EOM=17
‘SQLtable1 = “dbo.ACTLY_CPH” ‘Actual=”dbo.ACTTY_CPH”
For n = 0 To UBound(dbdFields)
UpdateRPCommTables dbdFields(n), SQLFields(n), “SalesF”, 8, “[dbo.ACTTY_CPH]”
Next n
For n = 0 To UBound(dbdFields)
UpdateRPCommTables dbdFields(n), SQLFields(n), “StockF”, 17, “[dbo.ACTTY_CPH]”
Next n
End Sub
Public Sub GetMISLAuto()
currEOPdate = EOMDate_Curr(Date – 3)
dbField = GetMonthSpan(currEOPdate, currEOPdate)
SQLField = UCase(Format(Mid(dbField, 2, 2) & “/” & Mid(dbField, 4, 2), “mmm”))
UpdateRPCommTables dbField, SQLField, “SalesF”, 8, “[dbo.ACTTY_CPH]”
UpdateRPCommTables dbField, SQLField, “StockF”, 17, “[dbo.ACTTY_CPH]”
End Sub
Public Sub UpdateRPCommTables(ByVal dbField As String, ByVal sField As String, rTable As String, ele As String, ByVal stable As String)
Dim DBSS As DAO.Database
Dim DBR As DAO.Database
Dim RSD As DAO.Recordset, RSS As DAO.Recordset
Set DBR = OpenDatabase(DB_RPCOMM)
Set RSD = DBR.OpenRecordset(“SELECT Dept, ” & dbField & ” FROM ” & rTable & ” ORDER BY Dept”, dbOpenDynaset)
Set DBSS = OpenDatabase(“SQLPROD_BT.dsn”, dbDriverNoPrompt, True, “ODBC; DRIVER={SQL SERVER};SERVER=mmm.sqldb.prod.bonton.com;DATABASE=production”)
‘get record keys
sql1 = “SELECT DEPT_CODE, SUM(” & sField & “) AS sData FROM ” & stable & _
” WHERE ELE_CODE =” & ele & ” GROUP BY DEPT_CODE ORDER BY DEPT_CODE”
Set RSS = DBSS.OpenRecordset(sql1, dbOpenDynaset)
Do While Not RSS.EOF
SysCmd acSysCmdSetStatus, “Retrieving data for ” & RSS!DEPT_CODE & ” field ” & dbField
RSD.FindFirst “Dept ='” & Format(RSS!DEPT_CODE, “000”) & “‘”
If RSD.NoMatch Then
RSD.AddNew
RSD!Dept = Format(RSS!DEPT_CODE, “000”)
Else
RSD.Edit
End If
RSD.Fields(dbField) = Round(Nz(RSS!sData, 0), 0)
RSD.Update
RSS.MoveNext
Loop
RSS.Close: Set RSS = Nothing
DoEvents
RSD.Close: Set RSD = Nothing
DBSS.Close: Set dbs = Nothing
DBR.Close: Set DBR = Nothing
SysCmd acSysCmdClearStatus
End Sub
Public Function EOMDate_Curr(ByVal xDate As Date)
‘Returns the last fiscal date of the month in which ‘xDate’ resides
Dim DBI As DAO.Database
Dim RSM As DAO.Recordset
Set DBI = OpenDatabase(DB_IMG1, , True)
Set RSM = DBI.OpenRecordset(“CntlDate”, dbOpenDynaset)
RSM.FindFirst “EOMDate >= #” & xDate & “#”
If RSM.NoMatch Then
EOMDate_Curr = Date
Else
EOMDate_Curr = RSM!EOMDate
End If
RSM.Close: Set RSM = Nothing
DBI.Close: Set DBI = Nothing
End Function
Public Function GetMonthSpan(ByVal startEOMDate As Date, ByVal endEOMDate As Date)
Dim DBI As DAO.Database, RSDate As DAO.Recordset
Set DBI = OpenDatabase(DB_IMG1, , True)
Set RSDate = DBI.OpenRecordset(“SELECT * FROM CntlDate WHERE EOMDate >=#” & startEOMDate & “# AND EOMDate <=#" & endEOMDate & "#", dbOpenDynaset)
GetMonthSpan = RSDate!dbField
RSDate.MoveNext
Do Until RSDate.EOF
GetMonthSpan = GetMonthSpan & "+" & RSDate!dbField
RSDate.MoveNext
Loop
RSDate.Close: Set RSDate = Nothing
DBI.Close: Set DBI = Nothing
End Function