How to display all records in query when using a criteria - database

I have created a query and i have a field called Department. I have added a criteria to that field that allows user interface, when you run the query it asks for you to enter the department name you want to display. If I choose to display all departments records what can I put in to display all departments? I remember something about entering * to display all records but this does not want to work

* only works with text fields and even then only when used with LIKE not =.
This is what I would use as filter:
[Department]=IIF([MyParameter]='',[Department],[MyParameter])
This should evaluate to always true when the Parameter is left empty.

Related

MsAccess - How to make an ID field fill in other fields in the form?

Problem:
I'm trying to make it so when a numerical field is filled in with a certain ID it fills in the other fields accordingly to what the first field was filled with. So if a person were to type in their ID it would populate it with their name accordingly.
Example:
But upon ID/numerical change I want it to do something like this:
Prior knowledge that may or may not help:
-I know this is possible with combo boxes but having a combo box with 2k-8k entries seems absurd
-I don't really think subform is optimal for this situation
-I think you can do this with "=DLookup" but I don't exactly understand how to pull it off
Please and thanks for any help. All is appreciated greatly!
Some built-in Access mechanisms:
Search field in the Navigation bar of the form.
Find feature (Ctrl-F).
Alternatively, with VBA you can use your own UI design and have more control:
Obtain the desired ID from the UI in whatever way you like - a textbox, a button and a popup, etc. Don't use a textbox that is bound to the actual ID field (ID fields should be read-only and you shouldn't use an edit field for a search field - keep them separate).
In VBA, obtain the ID that user searched for and then jump to that record using code like this:
Me.RecordsetClone.FindFirst "StudentID = " & studentID
If Not Me.RecordsetClone.NoMatch Then
Me.Bookmark = Me.RecordsetClone.Bookmark
End If
You don't need VBA for this. Simply add the Student ID textbox value as a parameter the form's query and let it filter the results according the ID provided.
The query should be something like this:
PARAMETERS [Forms]![YourMainForm]![YourIdTextBoxName] Long;
SELECT *
FROM YourTableName
WHERE ((([Student ID])=[Forms]![YourMainForm]![YourIdTextBoxName]));
When you add a new ID, requery the form to see the results.
Me.Requery

Printing records with condition Crystal reports

I am using stored procedure in mssql as backend, vb.net as frontend (just info).
There are a lot of records in the database and I am printing in crystal reports.
Now I want to filter the records from crystal report and not by adding a new parameter to procedure or changing database structure or else.
For now,Say there are columns : Name , Amount.
I want to put filter in amount like only display records whose amount above 100 or something. So other records with less than 100 should not be displayed.
This filter will be passed by the user so it'll be random.
I can't find a proper answer on internet. Might be a duplicate question, if so please post the link of the question if it is duplicated.!
Thanx anyways...!
In general the idea is to:
Create the parameter (user choose what will be the input/value) - link
Set filters, what values should be displayed in regards to parameter - link
On right side there is a DataExplorer window, where You need to add a Parameter (define his name, what question will be shown to user and what type the param will be / what values can be set inside).
Once done, You can jump to Data tab of a report, click Interactive Filter and specify which column must fit what condition with what value = Parameter (that one user will enter in Report).
Example: I will create AmountParam, with message "What should be the minimum amount?". Type will be set to Integer. Going to Report->Data->Interactive Filter, choose Amount as a Column, AmountParam as a Parameter and set condition Greater then (>).

MS ACCESS Report - Using CODE to change a value in a field from an OPTION Group to a different value

I have a report in ACCESS that Is based on a query of a table populated by a form with an Option group. ( to try to explain this better - Table is inspector qualifications, the query pulls all of the qualifications for the inspector, the qualifications are selected via option group on a form that populates the fields of the inspector qualification table.) Of course, the choices are stored as numeric values, "1, 2, 3 or 4" in the table, but 4 actually designates a N/A or NONE. Since everything is already built out this way, I am trying to write a code that will run when the report is generated (or opened,) that will take the "4" value entered (if the field equals that) and change it to a Null value /blank in the report - not in the query or table. I still want this report to generate everything else as is - show all records - just change the value if that particular option is the one shown in that field for that particular record.
Anyone know of a good way to do this? Any help would be GREATLY appreciated!!!!
You would just place an 'IIF' in the query that tests for the value you want to change, then either changes it to something else, or retains the original value. The below will test field 'Nbr1' for the presence of a 4, and if found, change it to 'N/A', otherwise it stays the same.
Note! You will need to change the control source in the report to reflect the name you provide (i.e. 'MyChange') because you can't keep the original name.
SELECT Table1.ID, Table1.EMPID, Table1.TestResult,
IIf([Nbr1]=4,"N/A",[Nbr1]) AS MyChange, Table1.Nbr2
FROM Table1;

Is it possible to create a parameter query in openoffice base?

In access it is very easy to use it:
BETWEEN [minimum] AND [maximum]
But what is the syntax in openoffice base?
There are two ways to do this. First is to have the query ask for user input. Colons are used to indicate user-input parameters, like this:
BETWEEN :MINIMUM AND :MAXIMUM
Second is to use a one-row filter table. Tie the user's form to this one row by making the form source something like SELECT * FROM "Filter" WHERE "FilterID" = 1. Then the user will enter the dates into the filter table, and the query will have a join to the filter table to determine the dates.

SSRS filter parameters

I have "Country" filter dropdown list in ssrs report. This contains all countries and it is a multiselect dropdownlist. If user selects "All" the reports sends all country names comma separated to a storedprocedure where I have the query to display data. In stored procedure i split the values and compare the data. No issues so far. Now what I want is, If user selects "All", i don't need to pass all comma separated values to SP, instead pass null. So in my sp i don't have to split or join the tables. The problem is identifying whether the user has selected the "All" check box in the report criteria.Is there a way to find this whether the "All" is selected?
the country is dynamic, so i don't have a lookup value to count all countries.
Parameters!Country.Count == 10 -- I can't do that because I don't know the 10.
You can create a separate dataset where you count the number countries .
Select count(countryName) as cntCountry from yourTable
Now you can compare this field cntCountry with the Parameters!Country.Count
Fields!cntCountry.Value==Parameters!Country.Count
or you can use CountRows function where in you pass the dataset
Parameters!Country.Count=CountRows(dataset1)
Edit : If the above one doesn't work
Parameters!Country.Count=CountRows()
Why don't you create a field in your dataset which will be storing the number of rows .while creating a dataset just get the row_number in your sql query and then match this value with Parameters!Country.Count

Resources