Access 2016 Form Query Issue - ms-access

The query grabs/obtains the criteria from a form. The problem is I have one field that is supplied in the data table that has multiple items separated by a comma. They are called Upgrade Codes:
Example: 18AAA, 8AAA, 2GAA, 1EAA
I am using Like [Forms]![Service Action Report]![Upgrade Codes] Or Like "*" & [Forms]![Service Action Report]![Upgrade Codes] & "*" in my query and it works all but also returns similar matches.
For example: 8AAA Form query search would return all records with 8AAA and also 18AAA since 8AAA is part of 18AAA this is not the desired outcome, is their a way to just get all records with the Upgrade Code supplied in the Form?

Try the following:
Like [Forms]![Service Action Report]![Upgrade Codes] Or
Like [Forms]![Service Action Report]![Upgrade Codes] & ", *" Or
Like "*, " & [Forms]![Service Action Report]![Upgrade Codes] & ", *" Or
Like "*, " & [Forms]![Service Action Report]![Upgrade Codes]
By including the * , and , * in your query it actually looks like the following for a upgrade code value like 8AAA:
Like "8AAA" Or
Like "8AAA, *" Or
Like "*, 8AAA, *" Or
Like "*, 8AAA"
The differend "or" seperated statements work like follows:
"8AAA":
Full match of 8AAA (there are no other values in the string)
"8AAA, *":
Match 8AAA only if it is the first comma seperated value in the list
"*, 8AAA, *":
Match 8AAA only if it is a middle value surounded by 2 commas
"*, 8AAA":
Match 8AAA only if it is the last value
By including the boundaries comma or beginning/end of the string you ensure that only full codes can match.

Related

DLookUp not working properly in Microsoft Access

Trying to pull the value in the Query to populate Form Field, not working with what I've tried.
Table 1: Quote Data
Fields: Quote #, Part #, CNC Hours
Table 2: Rate Chart
Fields: Rate Type, Cost ($)
Query 1: Cost of CNC
Fields: Quote #, Part #, CNC Hours, Parts Per Mag, Rate Type (Criteria: "3D Shop"), Cost ($)
Expression: Cost of CNC= [CNC Hours]*[Cost ($)]/[Parts Per Mag]
Main Form: Generate Quotes
SubForm: Quote Data Subform
Field Box: CNC $
Control Source: =DLookUp("[Cost of CNC]", "[Cost of CNC]", "[Part #]=" & [Forms]![Cost of CNC Subform]![Part #])
With the above Control Source I keep getting #Name? in the field text box CNC $.
I've also tried:
=DLookUp("[Cost of CNC]", "[Cost of CNC]", "[Part #] = " & [Part #]) but I get #Error.
What am I doing wrong?
I want the value in Cost of CNC (associated with the proper Part #) to populate Form Field: CNC $.
I got the following to work:
=DLookUp("[Cost of CNC]", "[Cost of CNC]", "[Part #]='"&[Part #]& "'")

How do I build an SSRS expression for the NoRowsMessage that shows report parameter values?

How do I build an SSRS expression for the NoRowsMessage that shows report parameter values?
something like:
="No locations were found for this street name : " + #StreetName
I have also tried this:
="No locations were found for this street name : " + Parameters!StreetName.Value
The second attempt worked fine:
="No locations were found for this street name : " + Parameters!StreetName.Value
I can add in carriage returns also as per this article which suggests the use of vbcrlf
=vbcrlf + "No locations were found for this street name : " + Parameters!StreetName.Value

IsNothing not working as expected in SSRS expression

I have a textbox that contains 2 fields with names in them, but the 2nd field can be empty. If there are 2 names I want it to display like this:
[name1], [name2]
if there is 1 name I want to display it like this:
[name1]
I have tried these 2 expressions:
=IIF(Fields!name2.Value Is Nothing, "", (", " + Fields!name2.Value))
=IIF(IsNothing(Fields!Joint_Name.Value), "", (", " + Fields!Joint_Name.Value))
however, in both cases if the 2nd name is blank it displays:
[name1],
any ideas how to get rid of that comma?
NULLs in your dataset usually come in as "".
=IIF(Fields!name2.Value = "", "", (", " + Fields!name2.Value))
I always recommend casting your Fields to the data type you intend to work with. A lot of the time the values come through in an unexpected data type and cause script errors.
=IIF(CSTR(Fields!name2.Value) = "", "", (", " + CSTR(Fields!name2.Value)))

Replace template smart tags <<tag>> to [tag] in mysql

I have an table name templateType, It has column name Template_Text.
The Template have many smart tags <> to [tag] using mysql, and I need to replace << to [ and >> with ].
Edit from OP's comments:
It is an template with large text and having multiple smart tags. As example : " I <<Fname>> <<Lname>>, <<UserId>> <<Designation>> of xyz organization, Proud to announce...."
Here I need to replace these << with [ and >> with ], so it will look like
" [Fname] [Lname], [UserId] ...."
Based on your comments, your MySQL version does not support Regex_Replace() function. So, a generic solution is not feasible.
Assuming that your string does not contain additional << and >>, other than following the <<%>> format, we can use Replace() function.
I have also added a WHERE condition, so that we pick only those rows which match our given substring criteria.
Update templateType
SET Template_Text = REPLACE(REPLACE(Template_Text, '<<', '['), '>>', ']')
WHERE Template_Text LIKE '%<<%>>%'
In case the problem is further complex, you may get some ideas from this answer: https://stackoverflow.com/a/53286571/2469308
A couple of replace calls should work:
SELECT REPLACE(REPLACE(template_text, '<<', '['), '>>', '])
FROM template_type

Long Query String Being Split

I'm using the query string to pass data between two PhoneApplicationPages but the destination page is recieving the data as multiple paameters instead of one big string. This is a problem as I'm passing data as JSON which cannot be desrialized if it's truncated mid flow.
The data I'm passing is:
NavigationService.Navigate("/MainPage.xaml?view=recipes&searchargs={"Author":null,"AuthorFilterType":2,"Categories":["1 Point","100-200 Calorie","1-3 grams Fat","3 Point","Baked Snack","Bakery & Baked Products","Banana","Beer","Boutique Wines","Bread","Breakfast","Breakfast Drinks","Cake","Cakes","Cocktails","Collectible Wines","Cookie","Cookie Dessert","Dairy","Dessert","Desserts","Diabetic","Drinks & Beverages","Fruit","Fruit Dessert","Fruit Drinks","Fruits","Gluten Free","High Fiber","Main Course","Main dish","Pasta","Pork","Raw Foods","Salads","Sandwiches","Shake & Smoothie","Side dish","Snack","Strawberry","Sweet Snack","Under 1 gram Fat","Under 100 Calorie","Vegetarian","Weight Watchers Points","Yogurt"],"Countries":[],"GlobalSearch":"","Ingredients":[],"MaxIngredients":0,"MinIngredients":0,"Name":null,"NameFilterType":2,"Rating":0,"Types":[]}");
But the query string contains this:
Is this a bug?
you need to escape the " used by json try this
NavigationService.Navigate("/MainPage.xaml?view=recipes&searchargs={\"Author\":null,\"AuthorFilterType\":2,\"Categories\":[\"1 Point\",\"100-200 Calorie\",\"1-3 grams Fat\",\"3 Point\",\"Baked Snack\",\"Bakery & Baked Products\",\"Banana\",\"Beer\",\"Boutique Wines\",\"Bread\",\"Breakfast\",\"Breakfast Drinks\",\"Cake\",\"Cakes\",\"Cocktails\",\"Collectible Wines\",\"Cookie\",\"Cookie Dessert\",\"Dairy\",\"Dessert\",\"Desserts\",\"Diabetic\",\"Drinks & Beverages\",\"Fruit\",\"Fruit Dessert\",\"Fruit Drinks\",\"Fruits\",\"Gluten Free\",\"High Fiber\",\"Main Course\",\"Main dish\",\"Pasta\",\"Pork\",\"Raw Foods\",\"Salads\",\"Sandwiches\",\"Shake & Smoothie\",\"Side dish\",\"Snack\",\"Strawberry\",\"Sweet Snack\",\"Under 1 gram Fat\",\"Under 100 Calorie\",\"Vegetarian\",\"Weight Watchers Points\",\"Yogurt\"],\"Countries\":[],\"GlobalSearch\":\"\",\"Ingredients\":[],\"MaxIngredients\":0,\"MinIngredients\":0,\"Name\":null,\"NameFilterType\":2,\"Rating\":0,\"Types\":[]}");
Thanks #Hermit Dave. For reference, the methods are Uri.EscapeDataString() and Uri.UnescapeDataString().