DLookup with Multiple Criteria - ms-access

I have an Access DB that has the following tables:
• 'Legal Entity Info' with [LegEntID] and [LegEntName]
• 'Policy Info' with [PolicyID] and [PolicyCarrierName]
• 'Policy Period' with [PolicyPeriodID] and [PolicyPeriod]
• 'Retention Amounts by Legal Entity' with [RetentionID], [PolicyPeriodID], [PolicyID], [LegEntID] and [RetentionAmount]
I have a form (Retention Payment Info Form), that pulls in the [PolicyPeriodID], [PolicyID], and [LegEntID] that are connected with a specific claim. I need to pull in the correct [RetentionAmount] that corresponds to the match in the 'Retention Amounts by Legal Entity' table. All three criteria ([PolicyPeriodID], [PolicyID], and [LegEntID]) have to be TRUE in order to pull in the correct [RetentionAmount].
On this form, I have an unbound field to show the [RetentionAmount] and I’m trying to write a DLookup function to select the [RetentionAmount] based on the selections on the form. Here is what I think it should look like, however, it’s not working.
=DLookUp("[RetentionAmount]",
"Retention Amounts by Legal Entity",
"[PolicyPeriodID]='" & Forms![Retention Payment Info Form].Form.[PolicyPeriodID] &
"' AND [PolicyID]='" & Forms![Retention Payment Info Form].Form.[PolicyID] &
"' AND [LegEntID]='" & Forms![Retention Payment Info Form].Form.[LegEntID] &
"'")
Any suggestions?

.Form is only needed when working with subforms.
http://access.mvps.org/access/forms/frm0031.htm is a good reference.
(You are here: Forms!Mainform!ControlName)
Correct syntax:
=DLookUp("[RetentionAmount]",
"Retention Amounts by Legal Entity",
"[PolicyPeriodID]=" & Forms![Retention Payment Info Form]![PolicyPeriodID] &
" AND [PolicyID]=" & Forms![Retention Payment Info Form]![PolicyID] &
" AND [LegEntID]=" & Forms![Retention Payment Info Form]![LegEntID])

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 #]& "'")

SSRS insert text when currency value ='GBP' or 'EURO' or 'USD' ect

i have been trying to work out how i can get a ssrs expression to insert text if the following currency appear in my invoices.
I would like,
if currency value = 'GBP' then show text "please pay UK BANK 000x000x00"
if currency value = 'Euro' then show text "please pay Euro BANK 000x000x00"
We have this to make the customer clear on which bank to pay into.
You can use SWITCH (similar to CASE in SQL) to display text based on the your value of the field. I have below an example with the sample you provided. Assuming your column name is "currency".
=SWITCH(
Fields!currency.value = "GBP", "please pay UK BANK 000x000x00",
Fields!currency.value = "Euro", "please pay Euro BANK 000x000x00")

Access 2016 Form Query Issue

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.

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

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().