access query no result - sql

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".

Related

Updating Fields in a Table with Values from Query

I'm struggling to understand why my event code for updating a Microsoft Access form field is only half working.
I have a query, we'll call DataQuery, that selects 3 column values from what we'll call Table1 that looks like the following:
**Part** **Description** **Revision**
10-123 Descrip1 A
10-342 Descrip2 D
10-232 Descrip3 E
I have another table where I'd like to assign the values from description and revision to fields in another table, we'll call Table2, based on picking a value in a combo box.
For instance:
We select a value of 10-342 in our combo box, then the values "Descrip2" and "D" get assigned to fields in Table2.
I can get this to work for whatever column I have in position one, but not position two.
My small vba code:
Private Sub ComboBox_AfterUpdate()
Me.DescriptionField_Table2 = Me.ComboBox.Column(1)
Me.RevisionField_Table2 = Me.ComboBox.Column(2)
Me.Requery
End Sub
Where "ComboBox" row source is DataQuery mentioned previously.
As stated, "Me.DescriptionField_Table2 = Me.ComboBox.Column(1)" works as intended, but the second line seems to be getting ignored. I feel like I'm missing something super simple here, but I'm can't figure it out.
I knew this was something simple...
Gustav, in the comments, answered my issue:
Set property ColumnCount of the combobox to 3.

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.

Count in Expression Builder in Access

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.

Access 2013 - Textbox formula producing a #Name? error

I have a textbox that I want to display one of 2 values -
1. A Date
2. the word "Incomplete"
I've tested this in the immediate window and it works perfectly.
Here's my logic:
If my desired condition were true, all records would have a date, if the dates are different or if some records have no date, then it would be "Incomplete"
This can be achieved analyzing this query called SP_ALL_ACTUALS_AS_OF:
SELECT tbl_SP.Actuals_AsOf
FROM tbl_SP
GROUP BY tbl_SP.Actuals_AsOf;
If the query is my desired condition then only one record comes up - "The date" that is in every single record in the Actuals_AsOf field of tbl_SP
However, if there are blanks here and there, there will be a minimum of 2 records, one of which will not be a date. So if I find 1 grouping that is not a date, then the entire condition should be "Incomplete"
so here is the formula in the textbox
IIf(DCount("[Actuals_AsOf]","SP_ALL_ACTUALS_AS_OF",IsDate([Actuals_AsOf])=False)=1,"Incomplete",Nz(DLookUp("[Actuals_AsOf]","SP_ALL_ACTUALS_AS_OF"),"Not pulled"))
I tested it in the immediate window and all is fine. However, when I implement this textbox on a form, I get a #Name? error. Why?
Try with:
=IIf(DCount("*","SP_ALL_ACTUALS_AS_OF","IsDate([Actuals_AsOf])=False")=1,"Incomplete",Nz(DLookUp("[Actuals_AsOf]","SP_ALL_ACTUALS_AS_OF"),"Not pulled"))
If you put your 'formula' in the Control Source of the Textbox you have to:
1) begin your Control Source string with an equal ('=')
2) Replace all commas (',') with semi-colon (';')
You can also set your Textbox with VBA in the onCurrent eventProc or onLoad event of your form, and your formula as to be written as in your post.

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.