J
jermaine123
I am a newbie when it comes to access, so I beg you to be patient. I
downloaded the Northwind 2007 db and made some adjustments. My goal is to
allow persons logging into the db to only customer records to which they are
assigned and administrators should view all records. I used the following as
criteria on the Customer Extended query...
Like IIf([TempVars]![CurrentUserLevel]=4,"*",[TempVars]![CurrentUserID]). The
query works fine and filters the records when I run it in access.
When I go back to the Order Details page and choose a customer I get the
error...
Too Few parameters. Expected 2. (3061)
RecordsetWrapper.OpenRecordset
strSQL = "SELECT * FROM [Customers Extended] WHERE [ID] = 52"
There is a module called RecordsetWrapper in NOrthwind and this is where the
error is pointing.
I have included the SQL from my query below and also the code for the
RecordsetWrapper OpenRecordset function.
I need your help URGENTLY.
CUSTOMERS EXTENDED QUERY
==========================
SELECT IIf(IsNull([Last Name]),IIf(IsNull([First Name]),[Company],[First Name]
),IIf(IsNull([First Name]),[Last Name],[Last Name] & ", " & [First Name])) AS
[File As], IIf(IsNull([Last Name]),IIf(IsNull([First Name]),[Company],[First
Name]),IIf(IsNull([First Name]),[Last Name],[First Name] & " " & [Last Name]))
AS [Contact Name], Customers.*, Customers.[PTS ID]
FROM Customers LEFT JOIN [Benefits Profile] ON Customers.ID = [Benefits
Profile].[Customer ID]
WHERE (((Customers.[PTS ID]) Like IIf([TempVars]![CurrentUserLevel]=4,"*",
[TempVars]![CurrentUserID])))
ORDER BY IIf(IsNull([Last Name]),IIf(IsNull([First Name]),[Company],[First
Name]),IIf(IsNull([First Name]),[Last Name],[Last Name] & ", " & [First Name])
), IIf(IsNull([Last Name]),IIf(IsNull([First Name]),[Company],[First Name]),
IIf(IsNull([First Name]),[Last Name],[First Name] & " " & [Last Name]));
RECORDSETWRAPPER OpenRecordset Function
=====================================
Public Function OpenRecordset(Domain As String, _
Optional Criteria As String = "1=1", _
Optional OrderBy As String, _
Optional RecordsetType As DAO.RecordsetTypeEnum
= dbOpenDynaset, _
Optional RecordsetOptions As DAO.
RecordsetOptionEnum _
) As Boolean
If Not m_rs Is Nothing Then
' Close the recordset so it can be re-used
CloseRecordset
End If
Dim strSQL As String
strSQL = "SELECT * FROM [" & Domain & "] WHERE " & Criteria
If OrderBy <> "" Then
strSQL = strSQL & " ORDER BY " & OrderBy
End If
On Error GoTo ErrorHandler
Set m_rs = CurrentDb.OpenRecordset(strSQL, RecordsetType,
RecordsetOptions)
OpenRecordset = True
Done:
Exit Function
ErrorHandler:
' verify the private Recordset object was not set
Debug.Assert m_rs Is Nothing
' Resume statement will be hit when debugging
If eh.LogError("RecordsetWrapper.OpenRecordset", "strSQL = " & Chr(34) &
strSQL & Chr(34)) Then Resume
End Function
downloaded the Northwind 2007 db and made some adjustments. My goal is to
allow persons logging into the db to only customer records to which they are
assigned and administrators should view all records. I used the following as
criteria on the Customer Extended query...
Like IIf([TempVars]![CurrentUserLevel]=4,"*",[TempVars]![CurrentUserID]). The
query works fine and filters the records when I run it in access.
When I go back to the Order Details page and choose a customer I get the
error...
Too Few parameters. Expected 2. (3061)
RecordsetWrapper.OpenRecordset
strSQL = "SELECT * FROM [Customers Extended] WHERE [ID] = 52"
There is a module called RecordsetWrapper in NOrthwind and this is where the
error is pointing.
I have included the SQL from my query below and also the code for the
RecordsetWrapper OpenRecordset function.
I need your help URGENTLY.
CUSTOMERS EXTENDED QUERY
==========================
SELECT IIf(IsNull([Last Name]),IIf(IsNull([First Name]),[Company],[First Name]
),IIf(IsNull([First Name]),[Last Name],[Last Name] & ", " & [First Name])) AS
[File As], IIf(IsNull([Last Name]),IIf(IsNull([First Name]),[Company],[First
Name]),IIf(IsNull([First Name]),[Last Name],[First Name] & " " & [Last Name]))
AS [Contact Name], Customers.*, Customers.[PTS ID]
FROM Customers LEFT JOIN [Benefits Profile] ON Customers.ID = [Benefits
Profile].[Customer ID]
WHERE (((Customers.[PTS ID]) Like IIf([TempVars]![CurrentUserLevel]=4,"*",
[TempVars]![CurrentUserID])))
ORDER BY IIf(IsNull([Last Name]),IIf(IsNull([First Name]),[Company],[First
Name]),IIf(IsNull([First Name]),[Last Name],[Last Name] & ", " & [First Name])
), IIf(IsNull([Last Name]),IIf(IsNull([First Name]),[Company],[First Name]),
IIf(IsNull([First Name]),[Last Name],[First Name] & " " & [Last Name]));
RECORDSETWRAPPER OpenRecordset Function
=====================================
Public Function OpenRecordset(Domain As String, _
Optional Criteria As String = "1=1", _
Optional OrderBy As String, _
Optional RecordsetType As DAO.RecordsetTypeEnum
= dbOpenDynaset, _
Optional RecordsetOptions As DAO.
RecordsetOptionEnum _
) As Boolean
If Not m_rs Is Nothing Then
' Close the recordset so it can be re-used
CloseRecordset
End If
Dim strSQL As String
strSQL = "SELECT * FROM [" & Domain & "] WHERE " & Criteria
If OrderBy <> "" Then
strSQL = strSQL & " ORDER BY " & OrderBy
End If
On Error GoTo ErrorHandler
Set m_rs = CurrentDb.OpenRecordset(strSQL, RecordsetType,
RecordsetOptions)
OpenRecordset = True
Done:
Exit Function
ErrorHandler:
' verify the private Recordset object was not set
Debug.Assert m_rs Is Nothing
' Resume statement will be hit when debugging
If eh.LogError("RecordsetWrapper.OpenRecordset", "strSQL = " & Chr(34) &
strSQL & Chr(34)) Then Resume
End Function