Count in Expression Builder in Access - sql

I have a Query named Data and it has 5 fields A, B ,C ,D, E. The Field A has always distinct values. I have form with where I have an unbound textBox. Through the Expression Builder for the text box. I use Count([Data!A]). When I go to the form view it shows me #Error.Where as the count in Query Data is 20. Where am I going wrong with the syntax?

It should read:
Count([Data]![A])
or just:
Count([A])

You can use
=DCount("Name_of_your_field";"Name_of_your_table")
In your unbound textbox if you don't absolutely need the query.

Related

SSRS - Need to hide column inside a group

I have a requirement to hide a column, if no value exits in that column. But i have a grouping(Parent : Employee Number, Child: Category) in the report. In some of the group result may have value, but some of then does not have.
Example screen shot attached.
If you check the above image, second employee(Shiju) does not have Category. So for the second employee(Shiju) - need to hide Category column.
I tried with "Column Visibility" option and Column Groups > select Column > write expression in "Hidden" property. Following is the expr.
=iif(CountDistinct(Fields!Cat.Value) = 0,True,False)
These two options did not work.
Please give any solution for this.
Thanks in advance.
Your expression is almost correct, you just need to format the 0 else it will treat it as nothing:
=IIF(CountDistinct(Fields!cat.Value)=cint(0),true,false)
The other thing to check is that the field is actually null or nothing rather than blank strings or spaces.

Expression Criteria for Access

I've created a database with about 15000 records and I want to create a form that filters the records according to entries inputed in textboxes through a Query. For the most of my columns i've used this Expression :
Like "*" & [Forms]![Testform]![Testtxt] & "*"
I use "Like" so that if the user decides not to input anything in a textbox, the query ignores that parameter. However when it comes to Dates (I have two columns that contain Dates) I can't make it ignore the empty textbox when the user decides not to write anything. Can you help me make the expression below show all the records in the query if the DateTesttxt is empty ?
> [Forms]![TestForm]![DateTesttxt]
If you're using query designer, just add another condition
Is Null
so visually in query builder it will be something like:
Criteria: > [Forms]![TestForm]![DateTesttxt]
or: Is Null
UPDATE:
This should work as well as a single expression:
Is Null Or > [Forms]![TestForm]![DateTesttxt]
and it is more correct solution in case if you have conditions on more than one column

Replace null with zero in crosstab query in Telerik

I just created 2 cross table using wizard function of Telerik Standalone report designer tool
since ISCED 5 has values for private and public its showing properly
using same query I created second cross tab and
but since ISCED 6 table doesnt have values for "public" section its showing like this
how to show as zero for public section 2nd cross tab (when no values for specific row)
You should modify the value of the field using an expression to evaluate your condition.
Select the textbox containing the data corresponding to the column you like to format when the value is null.
In the property pan on the right select "Value"
Write in there your expression, it should be something like this:
=Iif(Fields.MyField IS Null,"0",Fields.MyField)
You should also consider if the value instead of null is empty and eventually cover this case in the expression if applicable.
= Iif(Fields.MyField IS Null OR Fields.MyField = "", "0", Fields.MyField)
More information on conditional formatting can be found here.
Let us know if this works for you.

access query no result

Can some one tell me what is wrong with this query as I run this query and refer combo box value on the form but it is not returning any value?
SELECT [2G_KPI].CSSR
FROM 2G_KPI
WHERE ((([2G_KPI].CSSR) Like [Forms]![Form1]![segment_name].[Text]));
In ComboBox you there are 3 things, selectedValue , SelectedIndex and Selected text
Based on how you have coded,debug and check what value goes in the "predicate of your where clause".

How do I trim values or text that are selected in a ComboBox on an Access Form

I have a ComboBox on an Access 2007 form.
I created a table that holds text values that feeds into the ComboBox.
The text is too long so I would like the text to become trimmed to the last 5 characters
when any value is selected.
Example: In the ComboBox is: My Favorite Color is Green - 10001
But if the user select Green, I only want to insert the code 10001 in the query using trim.
How do I trimmed the values/text that are selected so that only the code is passed on to the rest of the query?
PARAMETERS [Forms].[ExampleForm]![cboColor] Text ( 255 );
SELECT FavColor
FROM COLOR
WHERE FavColor IS NOT NULL
HAVING (MAX(FavColorCode)=Forms.ExampleForm!Right(Trim([cboColor]),5))
I am getting an error message of Undefined Function.
Thanks everyone!
Guy
Just a tip, may be:
PARAMETERS [Forms].[ExampleForm]![cboColor] Text ( 255 );
SELECT FavColor
FROM COLOR
WHERE FavColor IS NOT NULL
AND (MAX(FavColorCode)=Right(Trim([Forms].[ExampleForm]![cboColor]),5))
Your SQL Statement was incorrect, try this now
It looks like #Luka showed you how to use those functions correctly with the value from cboColor. However, after fixing that part of your query, I suspect the db engine will throw a different error:
You tried to execute a query that does not include the specified expression 'FavColorCode' as part of an aggregate function.
I think you need to either do something else instead of the HAVING clause, or add a GROUP BY clause and an aggregate expression to your SELECT fields list. However I don't know how to fix the query because I don't understand what it's supposed to do.