i have a SSRS calculated filed where i can to concatenate a string and a field. How can i use the &. What's the best way to do it?
=iif(Fields!TYPE.Value= "A", "participated in" &Fields!NAME.Value& "'s game",
iif(Fields!TYPE.Value= "N", "did not participate in" & Fields!NAME.Value & "'s game",
"###ERROR###"
))
participated in Patrick's game
or
did not participate in Patrick's game
Try below
=IIF(Fields!TYPE.Value= "A", "participated in" AND Fields!NAME.Value= "'s game",
IIF(Fields!TYPE.Value= "N", "did not participate in" AND Fields!NAME.Value="'s game",
"###ERROR###",nothing ),nothing)
The & is the right way to go, to concatenate strings, you just missed a few spaces by the first and second &:
=IIF(Fields!TYPE.Value= "A",
"Participated in " & Fields!NAME.Value & "'s game",
IIF(Fields!TYPE.Value= "N",
"Did not participate in " & Fields!NAME.Value & "'s game",
"###ERROR###"
)
)
Related
I have the following expression as a placeholder within a textbox which gives me an error of Too many arguments, what can I do to change this please so that I can count the number of current interviews in dataset 1?
Probably very easy to figure but I've now been looking at it too long!
="<b>" & "Current Interviews" & "</b>" & vbcrlf & Sum(IIF(Fields!Count.Value, "DataSet1" = "Current",1,0))
I can't test at the moment but I think it should be
="<b>" & "Current Interviews" & "</b>" & vbcrlf & Sum(IIF(Fields!Count.Value = "Current",1,0), "DataSet1")
The scope expression ("DataSet1")should be the last argument in the SUM()
Been a while since I used Access and now stuck with a reporting problem.
I have a form, with various unbound controls. There a start date, end date and three levels of business/asset/location in combo boxes.
I can get my query and report to work for each of these as individual 'where' clauses when clicking on a button. That's fine.
However I would like to know what code I need to use when clicking a button so I can combine one or more of the above controls to filter the report i.e. my date range + Business, or date + Business + Asset etc.
I have been trawling the internet and testing different variations but seem to have gone through the error book so far.
My latest effort (on click) as one long string gives me a data mismatch error. If I remove the BU/Asset/Facility parts then my date range code does work. However, it's the combination of these I want to filter by.
DoCmd.OpenReport ReportName:="rptVerification_Results", View:=acViewPreview, WhereCondition:="[Date Entered] Between #" & Me.StartDate & "# AND #" Me.EndDate & "#""" And "BU = " & Me.cboBusiness & "" And "Asset = " & Me.cboAsset & "" And "Facility = " & Me.cboFacility & ""
As you can probably tell I'm winging it and need some direction please.
Thanks
It can be tricky to get the combination of quoted strings and form fields right, as you need to be aware of which quotes are being used to concatenate the WhereCondition string together and which quotes are being presented to the query engine. You also need to know which fields are text and which are numeric, because text fields need to be enclosed in quotes in the resulting string, while numerics don't. I'm assuming below that cboBusiness, cboAsset and cboFacility are all text.
I suggest you create a separate variable to store your WhereCondition in:
Dim myWhereCondition As String
myWhereCondition = "[Date Entered] BETWEEN #" & Me.StartDate & "# AND #" & Me.EndDate
& "# AND BU = '" & Me.cboBusiness
& "' AND Asset = '" & Me.cboAsset
& "' AND Facility = '" & Me.cboFacility & "'"
DoCmd.OpenReport ...
WhereCondition:=myWhereCondition
You can then create a debug breakpoint on the "DoCmd" statement and check the value of "myWhereCondition" in the Immediate window, to make sure it is formed correctly, before DoCmd runs.
IIRC, you can use apostrophes/single quotes as an alternative to double quotes in MS Access, as I've done above. If this is not the case, then each of the single quotes above would need to be converted to "double double quotes" (because a double quote on its own would terminate the string).
The somewhat messier "double quotes everywhere" version of the WhereCondition would be:
myWhereCondition = "[Date Entered] BETWEEN #" & Me.StartDate & "# AND #" & Me.EndDate
& "# AND BU = """ & Me.cboBusiness
& """ AND Asset = """ & Me.cboAsset
& """ AND Facility = """ & Me.cboFacility & """"
Note that if any of the cbo fields are numeric, you need to remove the corresponding single (or double double) quotes from each side of that field.
Try this WhereCondition:
Dim WhereCondition As String
' First, adjust the WhereCondition:
WhereCondition = "([Date Entered] Between #" & Format(Me!StartDate.Value, "yyyy\/mm\/dd") & "# And #" & Format(Me!EndDate.Value, "yyyy\/mm\/dd") & "#) And BU = '" & Me.cboBusiness & "' And Asset = " & Me.cboAsset & " And Facility = " & Me.cboFacility & ""
' Then, open report:
DoCmd.OpenReport ReportName:="rptVerification_Results", View:=acViewPreview, WhereCondition:=WhereCondition
I have a text search in my form, which uses the following code to filter my table of staff data:
Private Sub Command71_Click()
DoCmd.ApplyFilter "", _
"[Forename] Like '*" & [Forms]![StaffTotalQuery]![StaffTotalSearchText] & "*'" & _
"Or [Surname] Like '*" & [Forms]![StaffTotalQuery]![StaffTotalSearchText] & "*'" & _
"Or [ResearchArea]. Like '*" & [Forms]![StaffTotalQuery]![StaffTotalSearchText] & "*'" & _
"Or [Skills] Like '*" & [Forms]![StaffTotalQuery]![StaffTotalSearchText] & "*'" & _
"Or [EndDate] Like '*" & [Forms]![StaffTotalQuery]![StaffTotalSearchText] & "*'"
End Sub
The search works for all fields apart from [ResearchArea].
Both ResearchArea and Skills are ComboBoxes on my split form.
Both ResearchArea and Skills are fields in my Staff table.
New Skills can be added in the split form, but new ResearchArea's can only be added in the table.
The drop-down box on the Skills ComboBox contains repeated entries( e.g. if my listed skills on five staff are: "", "", "", "Accounting", "Accounting", then these options will appear in the drop-box), and blanks. I'd like it only to show unique entries, but also for me to be able to create new ones in this split form.
I'd also like to be able to search all staff's ResearchArea's, which I could do if they were text (like "Forename").
You have a dot to remove on this line:
"Or [ResearchArea]. Like '*" & [Forms]![StaffTotalQuery]![StaffTotalSearchText] & "*'" & _
Aside, you cannot search dates - in a meaningful way - as you do.
How do I get this expression to work in SSRS? I'm trying to get the field value, and if it is blank then to skip it and go to the next one.
Any help is appreciated.
=IIF(IsNothing(Fields!street1.Value), "", Fields!street1.Value) & vbcrlf & And
(IIF(IsNothing(Fields!street2.Value), "", Fields!street2.Value) & vbcrlf & And
(IIF(IsNothing(Fields!street3.Value), "", Fields!street3.Value)))
INPUT:
Street 1: Text 1
Street 2: null
Street 3: Text 2
Desired OUTPUT:
Text 1
Text 2
You can put your VBCRLF inside your IIF statements:
=IIF(IsNothing(Fields!street1.Value), "", Fields!street1.Value & vbcrlf) &
IIF(IsNothing(Fields!street2.Value), "", Fields!street2.Value & vbcrlf) &
IIF(IsNothing(Fields!street3.Value), "", Fields!street3.Value)
Thanks to advice from here (Looping through JSON using ASPJSON) and here (ASP JSON: Object not a collection), I am starting with a JSON array in Classic ASP:
{"markers": [{
"event":"hard_bounce",
"msg":{
"ts":1365109999,
"subject":"This an example webhook message",
"email":"example.webhook#mandrillapp.com",
"sender":"example.sender#mandrillapp.com",
"tags":[
"webhook-example"
],
"state":"bounced",
"metadata":{
"user_id":111
},
"_id":"exampleaaaaaaaaaaaaaaaaaaaaaaaaa",
"_version":"exampleaaaaaaaaaaaaaaa",
"bounce_description":"bad_mailbox",
"bgtools_code":10,
"diag":"smtp;550 5.1.1 The email account that you tried to reach does not exist. Please try double-checking the recipient's email address for typos or unnecessary spaces."
},
"_id":"exampleaaaaaaaaaaaaaaaaaaaaaaaaa",
"ts":1433940242
},
{
"event":"hard_bounce",
"msg":{
"ts":1365109999,
"subject":"This an example webhook message",
"email":"example.webhook#mandrillapp.com",
"sender":"example.sender#mandrillapp.com",
"tags":[
"webhook-example"
],
"state":"bounced",
"metadata":{
"user_id":111
},
"_id":"exampleaaaaaaaaaaaaaaaaaaaaaaaaa1",
"_version":"exampleaaaaaaaaaaaaaaa",
"bounce_description":"bad_mailbox",
"bgtools_code":10,
"diag":"smtp;550 5.1.1 The email account that you tried to reach does not exist. Please try double-checking the recipient's email address for typos or unnecessary spaces."
},
"_id":"exampleaaaaaaaaaaaaaaaaaaaaaaaaa1",
"ts":1433940242
}]
}
I am using Classic ASP and ASPJSON (http://www.aspjson.com/).
I can access the "_id" and "ts" values from the loop via:
Set oJSON = New aspJSON
'read the local JSON data
oJSON.loadJSON(str2)
For Each thingy In oJSON.data("markers")
Set this = oJSON.data("markers").item(thingy)
Response.Write _
this.item("_id") & ": " & _
this.item("ts") & "<br>"
Next
However, I am stuck trying to get at the data one level down, in the "msg" section.
I did try:
For Each thingy In oJSON.data("markers")
Set this = oJSON.data("markers").item(thingy)
Response.Write _
this.item("_id") & ": " & _
this.item("ts") & "<br>"
For Each thingy2 In oJSON.data("msg")
Set this2 = oJSON.data("this2").item(thingy2)
Response.Write _
this2.item("subject") & ": " & _
this2.item("diag") & "<br>"
Next
Next
But get this error:
Description: Object not a collection : .
Relating to this line:
For Each thingy2 In oJSON.data("msg")
I guess I am doing something silly, but I am stuck on this one and can't work out how to access that data.
You could access msg, which is a json object, within the loop you already have:
For Each thingy In oJSON.data("markers")
Set this = oJSON.data("markers").item(thingy)
Response.Write _
this.item("_id") & ": " & _
this.item("ts") & "<br>" &_
this.item("msg").item("subject") & ": " &_
this.item("msg").item("diag") & "<br>"
Next