I need to grab the Month and Year info from 2 date/time parameters of my report (Start date and End date) into a textbox.
I used the following expression -
=MonthName(Month(Parameters!StartDate.Value)) & Format(Year(Parameters!EndDate.Value)) & " to " & MonthName(Month(Parameters!EndDate.Value)) & Format(Year(Parameters!EndDate.Value))
to get it into something like e.g. March 2012 to August 2012.
It works, however I keep getting the following Warning:
[rsRuntimeErrorInExpression] The Value expression for the textrun ‘Textbox18.Paragraphs[0].TextRuns[0]’ contains an error: Conversion from type 'Date' to type 'Integer' is not valid.
Any ideas?
Thanks!
Is that the exact expression you are using? It doesn't seem like it is because:
that expression works without warnings (on my system)
it doesn't give the output that you indicate it does
the expression is wrong (it lists the year of the EndDate twice rather than the StartDate's year with the StartDate's month)
So I would guess that one of the functions in the actual expression is MonthName(Parameters!StartDate.Value) rather than MonthName(Month(Parameters!StartDate.Value)) which would give the error indicated.
This also works:
=MonthName(Month(Parameters!StartDate.Value)) & " " & Year(Parameters!StartDate.Value).ToString() & " to " & MonthName(Month(Parameters!EndDate.Value)) & " " & Year(Parameters!EndDate.Value).ToString()
Either that or this isn't the expression in Textbox18
Related
I'm writing a query to output to a report which will be printed and used as an internal business form. I'm having issues trying to get the date placeholders to output for records where these values are null. It's probably just easier to show the code:
IStatement: "For a period from " & Nz(FormatDateTime([DateFrom],2),"________") & " to " & Nz(FormatDateTime([DateTo],2),"________") & "inclusive at the rate of " & Nz(FormatCurrency([InclusiveRate]),"$______") & " per " & [InclusiveTimeFrame]
I'm trying to get a blank line eight spaces wide to display in the query when there is not date in the record. What the heck am I doing wrong?
FormatDateTime
will return string and never null hence your Nz isn't working. However, you could try iif(not isnull([DateFrom]), FormatDateTime([DateFrom],2),"________")
or write your custom function for validating the date field.
still very new to reports and all, currently trying to modify the time format for a report and I'd like it to appear as (ex.) 02:30:05 PM rather than the current/default 14:30:05.
Here's what I have so far:
="between the hours of " & Format(Parameters!StartTime.Value, "hh:mm:ss tt") & " and " & Format(Parameters!EndTime.Value, "hh:mm:ss tt") & " (" & Parameters!TimeZone.Label & ")"
The problem is that running the report it comes up as "between the hours of hh:mm:ss tt and hh:mm:ss tt" instead of "between the hours of 02:30:05 PM and 03:30:05 PM".
Any ideas as to why that might be? Thank you!
It appears that the data type for your parameter is causing this. You most likely currently have it set to Text. In the Parameter Properties, change it to Date/Time. This will allow the Format function to interpret it as a date and time instead of a string.
Alternatively, you can cast the parameter value as a date in the expression like this:
Format(CDate(Parameters!StartTime.Value), "hh:mm:ss tt")
Whenever I use this code
=IIf(JPCI_RPT_ReceiptStatusHeaderBLW.RECEIPT_ID_TYPE = "Trailer ID",
Code.StringToBarcode({JPCI_RPT_ReceiptStatusHeaderBLW.trailer_id}),
Code.StringToBarcode({JPCI_RPT_ReceiptStatusHeaderBLW.receipt_id_type}) & chr(10) &
Code.StringToBarcode({JPCI_RPT_ReceiptStatusDetailsBLW.item})
I get the following error...
Name 'JPCI_RPT_ReceiptStatusHeaderBLW' is not declared.
It's checking for dataset right? If not, how do I declare it?
The expression is looking for a field name and you're converting something like Crystal Reports to SSRS. In SSRS you refer to a field value with Fields!FieldName.Value.
Assumeing that you have a dataset with necessary fields, your expression would be something like:
=IIF(Fields!RECEIPT_ID_TYPE.Value = "Trailer ID",
Code.StringToBarcode(Fields!trailer_id.Value),
Code.StringToBarcode(Fields!receipt_id_type.Value) & chr(10) &
Code.StringToBarcode(Fields!item.Value) )
You had missed a closing parenthesis as well, but the error check didn't get that far.
I am attempting to add a running count to a time series table by API number. The running count would be an indicator of what production month a given well is in.
Table: MonthlyProd
Fields: API, YEAR, MONTH, LIQUID
Desired Field: RunningCount
Desired Result
I cannot quite figure out a Dcount expression in MS Access.
Edit* Current progress is as follows. Using the following Access query
ProdMonth: DCount("API","Monthly Production","API=" & [API] & " AND (YEAR<" & [YEAR] & " OR (YEAR=" & [YEAR] & " AND MONTHNUMBER<=" & [MONTHNUMBER] & "))")
Yields the following results
Running Total Not quite there
I assume I am off in the logic statement somewhere?
Try something like this:
DCOUNT("API","MonthlyProd","API=" & API & " AND (YEAR<" & YEAR & " OR (YEAR=" & YEAR & " AND MONTH<" & MONTH & "))")
This assumes API, MONTH, YEAR are numerical.
I found a solution.
I needed to format the Month and Year into a date serial number in one field.
The correct DCount function was as follows:
ProdMonth: DCount("API","MonthlyFix","API=" & [API] & " AND DateSer<=" & [DateSer])
Trying to get a count of all records from a table called "ComplaintsListMaster" that have a "ComplaintDate" greater than 11/1/2015. The correct value is around 70. But when I use the dcount pasted below, it returns 3951 which is almost every record in the table.
DCount("[ID]", "[ComplaintsListMaster]", "[ComplaintDate] >= 11/1/2015")
Any obvious mistakes?
We use an MS Access front end for a SQL Server backend
have you tried the following:
DCount("[ID]", "[ComplaintsListMaster]", "[ComplaintDate] >= #" & 11/1/2015 & "#")
dates are enclosed within the #date# number signs, in a similar way to how strings are enclosed in single quotes/apostrophe symbols 'string'.
Im not sure why you need both equal or greater than symbol =>11/1/2015 though. I would personally use >10/1/2015.
DCount("[ID]", "[ComplaintsListMaster]", "[ComplaintDate] > #" & 10/1/2015 & "#")
But both should work, so just personal preference I guess.
EDIT
I have just realised that I assumed dd/mm/yyyy and there was a possibility you are using mm/dd/yyyy so in that case, my answer would be >10/31/2015.
Enclose date in #, and always write your dates the US way (mm/dd/yyyy) in VBA:
DCount("[ID]", "[ComplaintsListMaster]", "[ComplaintDate] >= #11/1/2015#")
Means >= Nov-1.
The SQL Server backend has no impact in this case.
You probably don't have the date hardcoded, so follow this general guide.
Also, DCount needs no field to look up:
Dim FilterDate As Date
Dim FilterDateSql As String
FilterDate = DateSerial(Year(Date), Month(Date), 1)
FilterDateSql = Format(FilterDate, "yyyy\/mm\/dd")
DCount("*", "[ComplaintsListMaster]", "[ComplaintDate] >= #" & FilterDateSql & "#")