When trying to search for an entry using the volume criteria which is numerical data I get a debug error on the red line of code.Private Sub Command7_Click() Dim strCriteria As String If Len(Me.Volume & vbNullString) > 0 Then strCriteria = strCriteria & "[Volume] = " & Me.Volume & " AND " End If If Len(Me.Title & vbNullString) > 0 Then strCriteria = strCriteria & "[Movie Title] LIKE '*" & Me.Title & "*' AND " End If If Len(Me.Rating & vbNullString) > 0 Then strCriteria = strCriteria & "[Rating] = '" & Me.Rating & "' AND " End If If Len(strCriteria) < 1 Then MsgBox ("Please enter search criteria before attempting to search the database") Else strCriteria = Left(strCriteria, Len(strCriteria) - 5) If DCount("*", "search", strCriteria) = 0 Then MsgBox "No movies matching your search. Please refine your search and try again." Exit Sub Else DoCmd.OpenForm "search results" End If End If End Sub
The error comes up as a "data type mismatch in criteria expression" runtime error 3464
HI,
After reading your code I have concerns there may be a problem with
I'd set a breakpoint in my code and insure it is correct before moving forward. You may also need to do a TRIM on strCriteria to knock off the last space or two so it works.strCriteria = Left(strCriteria, Len(strCriteria) - 5)
hope this helps.
I also wonder why you use " AND " for Volumn but "*' AND " for the others but still remove exactly 5 characters?
One test is worth a thousand opinions.
Click the * below to say thanks.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks