I'm helping a friend with a winforms app loaded with crystal reports (two things I generally try to avoid so pardon my ignorance). Anyhow if I have a varchar database field:
2123456789
And want to display it on the **crystal**report as:
(212)-345-6789
How would I go about that without changing the stored procs, or the database data type (not trying to open that can of worms). From what I've been apply to surmise if it was a numeric or int field then I would be able to use the Format Object number tab. However this is not an option due to the datatyping.
EDIT
My goal is Formatting the data in the crystal report or back end code of the crystal report not the database or t-sql. Thanks
Set the field's display-string formula to:
Picture(CurrentFieldValue,"(XXX) XXX-XXXX")
try this:
Mid("2123456789",1,3)+" - "+Mid("2123456789",4,3)+" - "+ Mid("2123456789",7,4)
Related
I'm using the last version of Stimulsoft and C#. I have a report that gets data from SQL Server database and shows it.
My problem is that it rounds up without me adjusting it, like this :
123,456,789 => 123,456,792
My column in SQL Server:
in Stimulsoft:
What have I tried:
using this Custom format: #,0.##
using general or currency, instead of number
using this expression:
{IIF(Floor(MyTable.Price)==MyTable.Price,Floor(MyTable.Price),MyTable.Price)}
None of them worked ...
Please help
Inside Stimulsoft change type of Price column from float to decimal type.
then if you want set format
use this format type:
#,#0.#,#,#,#,#
I have a section in a Crystal Report that I want to suppress. I need to suppress it if there are 0 rows in a particular table in the dataset I am using. How would I do this? The Record Number special field provided appears to be an internal count of records in the report, and does not relate to the rows in the underlying data table.
I am creating the report from C#, but I cannot suppress the section from the code (it doesn't fit the project structure) - I must be able to do it from the report itself. The table concerned is definitely being passed to the report in the dataset, but it contains 0 rows. There must be a way to establish this inside the report itself.....
Can anyone please point me in the right direction?
In the Crystal Reports designer, view the properties of your section and there should be an option to Suppress, which you can give it a formula to return the appropriate boolean value.
You could then use the Count() function within that formula and (I believe) you can pass the name of your dataset to the Count() function to get the number of rows in that dataset.
I did the same thing on a complex report about 3 months ago but I don't have access to the report any more having changed jobs so I'm sorry I cannot be more specific, but hoepfully this gives you a starting point.
Just had a quick Google - try this.
If the section does only contain database fields and f.e. no text fields, then you could use the setting "Suppress Blank Section" in the "Section Export" (rightclick section) for that section.
As an alternative you could use the following formula in the "Suppress" in the "Section Export" for that section:
IsNull({table.field})
"{table.field}" is one of the fields in the dataset.
Hope this helps.
Go to "Section Expert" and click "Supress (No Drill-Down)" and try adding this:
IF {"DragYourFieldHere"} = "" then true else false
Create one dummy group,check on its header for each page,add the header in the group header of the dummy group.
Here is the deal, i have an SQL database with a Time(7) field, when i make the connection to CR in VS project the CR detects my Time database column as String... or so it makes me believe. i can import all my data from the database but when i try to format the filed in the report using CR formula i get the "to many arguments have been given to this function"
I've read a lot and tied many formulas and still cant correct this issue, my current formula code (as simple as it seems) is:
totext ({Checkin_CheckoutT.Checkin_time}, "hh:mm")
I've tried another code that seems to be on the right track:
Totext(CTime({Checkin_CheckoutT.Checkin_time}), "hh:mm")
but with this one i get the "bad time format string " when i refresh my report.
I've been looking at this the whole day and still no solution...Please Help!
Current software:
SQL managger 2012,
VS 2012,
Sap CR 13.0.5
Time(7) is just a very precise time field, but Crystal (or at least the version being used) was built before Time(7) existed, so it doesn't know what to do with it. The result is a string of the time in hh:mm:ss.nnnnnnn format. If all you need is the hours and minutes in a string, then use Left({Checkin_CheckoutT.Checkin_time}, 5) to pull out the first 5 characters (which would be the hh:mm part).
You can also flip it back to Crystal time afterwards if that is what is needed: CTime(Left({Checkin_CheckoutT.Checkin_time}, 5))
If you Crystal is reading it as a string field and you don't wanna mess with SQL code to convert it this should work. Im pretty sure I remember that SQL time(7) field is in hh:mm:ss.ms
time(tonumber(split({yourtime7string},":")[1]),tonumber(split({yourtime7string},":")[2]),0)
from there right click, format field and tell Crystal how you want it to look.
if you must format it in the formula
totext(time(tonumber(split({yourtime7string},":")[1]),tonumber(split({yourtime7string},":")[2]),0),"HH:mm")
I would like to understand the concept behind this.
I am making a database in c#. Now, I wish to have only date instead of date and time.
So, I went for the following command in sql query pane:
SELECT CONVERT(varchar, deal_start_date, 101) AS 'deal_start_date'
FROM client
The desired result comes but the data becomes read only and hence cant be edited.
Further, it does not stay permanently. I mean,
On clicking show table data again the date-time format comes.
Can any one tell me why the cells become read-only and how to keep the changes permanently through UI only??
Many thanks.
My guess on the read only part, is that since you are now converting the original value, you loose the link towards the column in the database. Just like a computed column can't be edited (how would you for example write to the column from the query that is defined as A+B as 'C'.
Inside what type of component are you showing this in your GUI? Maybe you can ahve your query remain as SELECT deal_start_date FROM client, and filter out the time part from your component?
Or, if you don't use the time in any other place in your application, change the column from datetime to date in the database.
I did not get a perfect answer but I found an alternative. I was trying with datetime datatype in MS SQL database. When I changed it to varchar(12), I got the desired result. i.e in date format.
(Thanks to insights provided by Øyvind Knobloch-Bråthen )
This is actually improper to follow as with size 12 in varchar, the time part is truncated.
(If the size of varchar is increased, the time part will be present)
But It served my purpose.
But I am still waiting for a correct answer,if any.
In my Crystal Report, I want to show the Field values in Upper Case.Is there any way to do this?
You don't need to create a separate Formula Field to achieve this result.
Instead, add the following to the field's Display String conditional formula:
UpperCase(CurrentFieldValue)
Here you go ... http://www.crystalreportsbook.com/Forum/forum_posts.asp?TID=8823
You will notice in this example they are using the UpperCase function of Crystal Reports. So, all you need to do is say UpperCase(some field name) and that take care of it for you.