Error 3085: Undefined function 'N' in expression. - Access 2010

Joined
Nov 27, 2013
Messages
1
Reaction score
0
Hi, I am working on an Access 2010 database and trying to create a Form that will allow me to custom filter and sort reports. When I click my apply filer command button i am getting a runtime error 3085 - Undefined finction 'N' in expression. I cannot resolve this error. Please help


Here is the code for the command button. I Bolded the text that gets highlighted when the debugger runs.


Private Sub cmdApplyFilter_Click()
Dim varItem As Variant
Dim strCategory As String
Dim strBuyer As String
Dim strTypeExpense As String
Dim strFilter As String
Dim strSortOrder As String
' Check that the report is open
If SysCmd(acSysCmdGetObjectState, acReport, "rptJobs_All") <> acObjStateOpen Then
MsgBox "You must open the report first."
Exit Sub
End If
' Build criteria string from lstCategory listbox
For Each varItem In Me.lstCategory.ItemsSelected
strCategory = strCategory & ",'" & Me.lstCategory.ItemData(varItem) & "'"
Next varItem
If Len(strCategory) = 0 Then
strCategory = "Like '*'"
Else
strCategory = Right(strCategory, Len(strCategory) - 1)
strCategory = "IN(" & strCategory & ")"
End If
' Build criteria string from lstBuyer listbox
For Each varItem In Me.lstBuyer.ItemsSelected
strBuyer = strBuyer & ",'" & Me.lstBuyer.ItemData(varItem) & "'"
Next varItem
If Len(strBuyer) = 0 Then
strBuyer = "Like '*'"
Else
strBuyer = Right(strBuyer, Len(strBuyer) - 1)
strBuyer = "IN(" & strBuyer & ")"
End If
' Build criteria string from lstTypeExpense listbox
For Each varItem In Me.lstTypeExpense.ItemsSelected
strTypeExpense = strBuyer & ",'" & Me.lstTypeExpense.ItemData(varItem) & "'"
Next varItem
If Len(strTypeExpense) = 0 Then
strTypeExpense = "Like '*'"
Else
strTypeExpense = Right(strTypeExpense, Len(strTypeExpense) - 1)
strTypeExpense = "IN(" & strTypeExpense & ")"
End If
' Build filter string
strFilter = "[Category] " & strCategory & _
" AND [Buyer] " & strBuyer & _
" AND [TypeExpense] " & strTypeExpense
' Build sort string
If Me.cboSortOrder1.Value <> "Not Sorted" Then
strSortOrder = "[" & Me.cboSortOrder1.Value & "]"
If Me.cmdSortDirection1.Caption = "Descending" Then
strSortOrder = strSortOrder & " DESC"
End If
If Me.cboSortOrder2.Value <> "Not Sorted" Then
strSortOrder = strSortOrder & ",[" & Me.cboSortOrder2.Value & "]"
If Me.cmdSortDirection2.Caption = "Descending" Then
strSortOrder = strSortOrder & " DESC"
End If
If Me.cboSortOrder3.Value <> "Not Sorted" Then
strSortOrder = strSortOrder & ",[" & Me.cboSortOrder3.Value & "]"
If Me.cmdSortDirection3.Caption = "Descending" Then
strSortOrder = strSortOrder & " DESC"
End If
End If
End If
End If
' Apply filter and sort to report
With Reports![rptJobs_All]
.Filter = strFilter
.FilterOn = True
.OrderBy = strSortOrder
.OrderByOn = True
End With
End Sub
 
Joined
Feb 9, 2012
Messages
25
Reaction score
0
There is a problem somewhere within the filter possibly to do with syntax but as your code is quite long I would output the strFilter variable (to a msgbox or the Watch window) and then check it through. Post it here if you can't see the problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top