The output from my Parameter is FirstName LastName.
I want the final to be FirstName_LastName.jpg. Below is what I would do in SQL but how can I do the same in my SSRS report?
update #signatures set fullname = REPLACE(REPLACE(filename, ' ', '_'),' ','.jpg')
I tried the following but the result was FirstName LastName_.jpg.
=Format(Parameters!Signature.Value, (Parameters!Signature.Value)&"")&".jpg"
=Replace(Parameters!Signature.Value, " ", "_") & ".jpg"
Related
I have a stored procedure and a part of it is:
SET #TableAlias = " ls_flock AS _flk ";
SET #Select = CONCAT(
" _flk.Id as Id, _flk.Code as Code, ",
CONCAT(" _em.FirstName", " ", "_em.LastName "), -- here I want to CONCAT 2 columns as one field.
" as FlockManager"
);
SET #Join = " JOIN employee as _em ON _flk.EmployeeId = _em.Id ";
I am unable to CONCAT two columns as a field with a CONCAT function.
And if I remove following line, code works fine:
CONCAT(" _em.FirstName", " ", "_em.LastName "), -- here I want to CONCAT 2 columns as one field.
" as FlockManager"
I'm getting this error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.LastName as FlockManager FROM ls_flock AS _flk JOIN employee as _em ON _flk.' at line 1
I suspect that you want to generate a query string that uses CONCAT() - because I see that the table alias _em is declared further in the #Join variable. For this, you would need to move the function inside the query string.
SET #Select = CONCAT(
" _flk.Id as Id, ",
"_flk.Code as Code, ",
"CONCAT(_em.FirstName, "" "", _em.LastName) s FlockManager"
;
And then, you just don't need the outer CONCAT():
SET #Select =
" _flk.Id as Id, _flk.Code as Code, CONCAT(_em.FirstName, "" "", _em.LastName) as FlockManager";
I have an access 2013 table that houses one field with comma separated values. I have created a second table that I need to parse the results into with a structure like so
uPPID number
value1 short text
value2 short text
value3 short text
value4 short text
I am dynamically creating the table so it will always have enough "value" fields to accommodate for the number that will be parsed out. Sample data is like such:
uppID values
aeo031 boat, goat, hoat, moat
And I would want the field mappings to go like such
uPPID = aeo031
value1 = boat
value2 = goat
value3 = hoat
value4 = moat
How can access vba parse out a csv list from one field to many?
There are probably faster/better solutions than the follwing VBA loop that inserts records one by one in the destination table. But for instance it does the job.
TableCSV is the name of the source table
TableFields is the name of the destination table
The constant maxValues specifies the number of fields values available
The query composes dynamically the INSERT INTO statement after composing the values fields; it completes it to provide all the columns, and adds the surrounding quotes '...'. (p.s. it could be simplified if we can insert without specifying all column values..)
.
Sub splitTable()
Const maxValues As Long = 4 ' <-- Set to number of value fields in destination table
Dim query As String, values As String, rs
Set rs = CurrentDb.OpenRecordset("TableCSV")
Do Until rs.EOF
values = rs!values ' next we add commas to provide all fields
values = values & String(maxValues - UBound(Split(values, ",")) - 1, ",")
values = "'" & Replace(values, ",", "','") & "'" ' 'a', 'b', '', '' etc
query = "INSERT INTO TableFields VALUES (" & rs!uPPID & "," & values & ")"
Debug.Print query
CurrentDb.Execute query
rs.moveNext
Loop
End Sub
When I set up Allen Browne's ConcatRelated in a query to use a date range, I get ever comment in that range in each comment field. I want to group by an assembly line name but I get each line's comments. My SQL query is below. Any help would be greatly appreciated.
I have tried a sub query but I still get the same result or a syntax error depending on how I format.
SELECT
Asm_Equipment_Rate.Line_Name,
Avg(Asm_Equipment_Rate.Std_Pnls_Lbr_Hr) AS RAsm_Line_Std_Hrs,
Sum(Asm_Prod_Data.Lbr_Hrs) AS RAsm_Line_Total_Hrs,
([RAsm_Line_Std_Hrs]*[RAsm_Line_Total_Hrs]) AS RT100_Pct_Target,
([RT100_Pct_Target]*0.9) AS RT90_Pct_Target,
Sum(Asm_Prod_Data.Produced) AS RTotal_Produced,
Sum(Asm_Prod_Data.Backflushed) AS RTotal_Backflushed,
[RTotal_Produced]/[RT100_Pct_Target] AS RAsm_Line_EFF,
Sum(Asm_Prod_Data.Scrap_Qty) AS RAsm_Scrapped_Panels,
Sum(Asm_Prod_Data.Reworked) AS RAsm_Reworked_Panels,
IIf(([RAsm_Scrapped_Panels]+[RAsm_Reworked_Panels])=0,1,1-
([RAsm_Scrapped_Panels]+[RAsm_Reworked_Panels])/([RAsm_Scrapped_Panels]+
[RAsm_Reworked_Panels]+[RTotal_Produced])) AS RFYP,
ConcatRelated
('Comments',
'Asm_Prod_Data',
'PA_date Between ' & Format([Forms]![Date Prompt]!
[txtBDate],'\#yyyy-m-d\#') & ' And ' & Format([Forms]![Date Prompt]!
[txtEDate],'\#yyyy-m-d\#'),
'Comments',
', ') AS RConCat_Comments
FROM Asm_Equipment_Rate INNER JOIN Asm_Prod_Data ON
Asm_Equipment_Rate.Equipment = Asm_Prod_Data.P_Line
WHERE (((Asm_Prod_Data.PA_Date) Between [Forms]![Date Prompt]![txtBDate]
And [Forms]![Date Prompt]![txtEDate]))
GROUP BY Asm_Equipment_Rate.Line_Name;
Regards,
Bill
change the WHERE clause to
'PA_date Between ' &
Format([Forms]![Date Prompt]![txtBDate],'\#yyyy-m-d\#') &
' And ' & Format([Forms]![Date Prompt]![txtEDate],'\#yyyy-m-d\#') &
' And P_Line=' & Asm_Prod_Data.P_Line,
You'll need to quote the value if P_Line is text.
Also, I think when you call a function you need to use double quotes inside the function call, although if what you have there is working, that's not true. Maybe it's changed for later Access versions.
EDIT: I mean the WHERE clause in the function call
Try this
SELECT
Asm_Equipment_Rate.Line_Name,
ConcatRelated
('Comments',
'Asm_Prod_Data',
'PA_date Between '
& Format([Forms]![Date Prompt]![txtBDate],'\#yyyy-m-d\#')
& ' And ' & Format([Forms]![Date Prompt]![txtEDate],'\#yyyy-m-d\#')
& ' And P_Line=' & Asm_Prod_Data.P_Line,
'Comments',
', ') AS RConCat_Comments
FROM Asm_Equipment_Rate INNER JOIN Asm_Prod_Data
ON Asm_Equipment_Rate.Equipment = Asm_Prod_Data.P_Line
WHERE (((Asm_Prod_Data.PA_Date) Between [Forms]![Date Prompt]![txtBDate]
And [Forms]![Date Prompt]![txtEDate]))
GROUP BY Asm_Equipment_Rate.Line_Name,
ConcatRelated
('Comments',
'Asm_Prod_Data',
'PA_date Between '
& Format([Forms]![Date Prompt]![txtBDate],'\#yyyy-m-d\#')
& ' And ' & Format([Forms]![Date Prompt]![txtEDate],'\#yyyy-m-d\#')
& ' And P_Line=' & Asm_Prod_Data.P_Line,
'Comments',
', ');
It's unfortunate but the GROUP BY expression has to be identical to the one in the SELECT clause, no matter how complex.
I need to display data in a lastname, firstname, salutation format. However there are a few rare instances where salutation is null, so I wouldn't want to display firstname, if salutation is null. Or there (doubtful) could be a possibility that firstname is null and salutation so I wouldn't want to show lastname, , ,.
How can I in my query use a condition to only include the comma if the next field is not null?
NameWithSal: [LastName] + ", " + [FirstName] + ", " + [Salutation]
In Access, what you have will result in null if any of the fields are null. The following should provide what you specified. [LastName] & ", " + [FirstName] & ", " + [Salutation]
i am doing queries practice in Microsoft access. i want to concatenate the first name with the fax number.. the fax number is like (123)555-0103 ..
i`m doing that
select [first name] +' ''s Fax Number is' +str(fax number) as [Mariya`s Fax Number]
from employees where id =4;
but it is giving error..
That would be:
select [first name] & " ''s Fax Number is " & [fax number] as [Mariya`s Fax Number]
from employees where id =4
You should use & to concatenate
You should use '' for each single quote
You should use double quotes (") for strings.