Filter not Working on Report

Willem2904

Registered User.
Local time
Today, 15:34
Joined
Aug 17, 2015
Messages
20
Hi all,

I am quite new to Access and have been working with a sample DB from Microsoft.
I have been looking for some ways to filter a report based on the values in some comboboxes, and have followed the instructions on a website (can't post link yet)

I also looked at this file (**can't post link yet**) and it seems like everything works fine here. So I started a new DB with my own table, and tried to do the same thing as in this file.
Everything works fine.

But when I try all these steps in my own DB (the sample DB from Microsoft), it doesn't work.

When I filter by "Status" (f.ex: "In Progress" or "Not Started"), it seems to work fine.

However, when I filter by "Assigned To", I get the following error message: "Data Type Mismatch in criteria expression". So I googled this error message , but this field has nothing to do with any date formatting.

It gets even stranger when I try to filter by "Project":
Then a new pop up appears and asks me to enter the "Project".
No matter what I enter, the report turns blank

I am completely lost here... What to do? :)
 

Attachments

  • Non-filtered.PNG
    Non-filtered.PNG
    71.7 KB · Views: 203
  • In progress.PNG
    In progress.PNG
    53.7 KB · Views: 221
  • Assigned To.PNG
    Assigned To.PNG
    68.4 KB · Views: 204
  • Project.jpg
    Project.jpg
    92.7 KB · Views: 195
  • Blank.PNG
    Blank.PNG
    55.1 KB · Views: 215
It appears the attachements were included in the post after all :-)
 
What is the code? It sounds like the failing ones may be numeric data types rather than text, or vice-versa.
 
Row Source:

Project:
SELECT DISTINCT [Project Name] FROM Projects ORDER BY [Project Name];

Task:
SELECT DISTINCT [Title] FROM Tasks ORDER BY [Title];

Status:
SELECT DISTINCT [Status] FROM Tasks ORDER BY [Status];

Assigned To:
SELECT DISTINCT [Full Name] FROM Employees ORDER BY [Full Name];

Status:
SELECT DISTINCT [Status] FROM Tasks ORDER BY [Status];


Filter Button:
Private Sub Filter_Click()
Dim strSQL As String, intCounter As Integer
' Build SQL String.
For intCounter = 1 To 5
If Me("Filter" & intCounter) <> "" Then

strSQL = strSQL & "[" & Me("Filter" & intCounter).Tag & "] " _
& " = " & Chr(34) & Me("Filter" & intCounter) & Chr(34) & _
" And "
End If
Next

If strSQL <> "" Then
' Strip Last " And ".
strSQL = Left(strSQL, (Len(strSQL) - 5))
' Set the Filter property.
Reports![rptTasks].Filter = strSQL
Reports![rptTasks].FilterOn = True
End If
End Sub
 
Like this?

Private Sub Filter_Click()
Dim strSQL As String, intCounter As Integer
' Build SQL String.
For intCounter = 1 To 5
If Me("Filter" & intCounter) <> "" Then

strSQL = strSQL & "[" & Me("Filter" & intCounter).Tag & "] " _
& " = " & Chr(34) & Me("Filter" & intCounter) & Chr(34) & _
" And "
End If
Next
Debug.Print strSQL

If strSQL <> "" Then
' Strip Last " And ".
strSQL = Left(strSQL, (Len(strSQL) - 5))
' Set the Filter property.
Reports![rptTasks].Filter = strSQL
Reports![rptTasks].FilterOn = True
End If
End Sub

The Data Type of "Full Name" is a calculated field, being "First Name"&" "&"Last Name"
 
Here's a screenshot.
 

Attachments

  • Formula.PNG
    Formula.PNG
    23.4 KB · Views: 201
Nothing would "happen", other than the SQL showing up in the Immediate Window.
 
The prompt on project is likely because "Project" is not a field in the data.
 
Please have a look at the 2 files attached.
The table "Projects" contains the field "Project Name" which I used in the row Source.
The Table "Tasks" contains the fields "Title" and "Status", which I also used in the Row Source.

So if Status works, why doesn't title work? :(
 

Attachments

  • Project Data Type.PNG
    Project Data Type.PNG
    13.1 KB · Views: 179
  • Tasks Data Types.PNG
    Tasks Data Types.PNG
    12.4 KB · Views: 183
If you look at the screenshot in post 9, the field name there is "Project", not "Project Name". Your tag on that field appears to be incorrect.
 
OMG that did it! GREAT!

Now just one issue left, and that is the "Full Name"
This one still shows a pop up.

Could that be due to:
1. A space between "Full" and "Name"?
2. the fact that this is a calculated field?
 
What does that popup look like? I don't see one in the earlier posts.
 
The enter parameter value is Access telling you it can't find something. I don't see Full Name in either of your table views. Should it be something else, or ?
 
The field "Full Name" is a calculated field, using [First Name] & " " & [Last Name]
I also added a new collumn to the table "Employees" called FullName.
I added FullNames manually, and tried with that field. Still doesn't work...
Full name.PNG
 
For the new collumn, I tried the following code:
SELECT DISTINCT [FullName] FROM Employees ORDER BY [FullName];
Full Name new.PNG
Full Name new 2.PNG
 
That's in a different table; is that table/field part of the report's source?
 

Users who are viewing this thread

Back
Top Bottom