Hi!
I’m creating a new view of an existing database, planning a new search form for it. After I filled the tables with some test data somehow this error massage appeared:
“This expression is typed incorrectly, or it is too complex to be evaluated. For example, a numeric expression may contain too many complicated elements. Try simplifying the expression by assigning parts of the expression to variables. (Error 3071)”
The massage happens every time I changing the record on the filtered main form (using the built-in Access navigation buttons). Funny thing is: everything seems to be working just fine; I just have to OK the error every time.
This is what I’m trying to do: on the main form there is a “search” button, the user clicks on it and a new form appear where he can set the criteria. After confirming the form goes away and the main form is filtered by the given information. I wanted a search where 1. they don’t have to use exact matches 2. they can filter by two or more fields in the same time.
Looking for the problem I found that this error shows when working with queries, usually caused by date fields. But I don’t have any date on the search from.
Ah yes, I tried repairing the database without any luck.
Any help would be appreciated. Please keep in mind I’m not educated in IT so fundamentals could be missing: S
This is the original code:
Module1:
Main form:
„p_search” form:
On the road to solve the issue I reduced (and slightly altered) the code to this (everything else is commented out), but the error still occurs:
„p_search” form:
I’m creating a new view of an existing database, planning a new search form for it. After I filled the tables with some test data somehow this error massage appeared:
“This expression is typed incorrectly, or it is too complex to be evaluated. For example, a numeric expression may contain too many complicated elements. Try simplifying the expression by assigning parts of the expression to variables. (Error 3071)”
The massage happens every time I changing the record on the filtered main form (using the built-in Access navigation buttons). Funny thing is: everything seems to be working just fine; I just have to OK the error every time.
This is what I’m trying to do: on the main form there is a “search” button, the user clicks on it and a new form appear where he can set the criteria. After confirming the form goes away and the main form is filtered by the given information. I wanted a search where 1. they don’t have to use exact matches 2. they can filter by two or more fields in the same time.
Looking for the problem I found that this error shows when working with queries, usually caused by date fields. But I don’t have any date on the search from.
Ah yes, I tried repairing the database without any luck.
Any help would be appreciated. Please keep in mind I’m not educated in IT so fundamentals could be missing: S
This is the original code:
Module1:
Code:
Option Compare Database
Global myFilter As String
Option Explicit
Code:
Private Sub Search_Click()
myFilter = ""
‘The search panel will open where the SQL WHERE expression (myFilter) is built
DoCmd.OpenForm "p_search", , , , acNormal, acDialog
If myFilter = "" Then Exit Sub
Me.Filter = myfilter
Me.FilterOn = True
If Me.Recordset.RecordCount = 0 Then
MsgBox ("No results!")
myFilter = ""
Me.FilterOn = False
End If
End Sub
Code:
Private Sub OK_Click()
’If everything left blank just close the form
If IsNull(Me.TextX) And IsNull(Me. ComboXX) And IsNull(Me. TextXXX) And //…// Then
DoCmd.Close acForm, "p_search"
Exit Sub
End If
’If field isn’t empty start to build an SQL WHERE expression
If Nz(Me.TextX, "") <> "" Then
myFilter = "[p_00_number] Like '*" & Replace(Me.TextX, "'", "''") & "*' And "
End If
If Nz(Me. ComboXX, "") <> "" Then
myFilter = myFilter & "[p_00_name] Like '*" & Replace(Me. ComboXX, "'", "''") & "*' And "
End If
If Nz(Me. TextXXX, "") <> "" Then
myFilter = myFilter & "[p_00_person] Like '*" & Replace(Me. TextXXX, "'", "''") & "*' And "
End If
// … //
’Delete the “ and “ from the end of myFilter if there is anything in it
If myFilter <> "" Then
myFilter = Left(myFilter, Len(myFilter) - 5)
‘If myFilter is empty just leave the Filter empty and off
Else
Me.Filter = ""
Me.FilterOn = False
End If
‘Go back to the main form
DoCmd.Close acForm, "p_search"
End Sub
„p_search” form:
Code:
Private Sub OK_Click()
If Nz(Me.TextX, "") <> "" Then
myFilter = "[p_00_number]" & " Like " & Chr$(34) & "*" & Me.TextX & "*" & Chr$(34) & " And "
End If
If myFilter <> "" Then
myFilter = Left(myFilter, Len(szűrő) - 5)
Else
Me.Filter = ""
Me.FilterOn = False
End If
DoCmd.Close acForm, "p_ search "
End Sub
Last edited: