Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: List Horizontal Post Reply Post New Topic
Author Message
cmt.it.steve
Newbie
Newbie


Joined: 11 May 2011
Online Status: Offline
Posts: 3
Quote cmt.it.steve Replybullet Topic: List Horizontal
     Posted: 11 May 2011 at 1:58pm
I have some data that I need to list horizontally and I didn't know the best way about this. I've tried the Section Expert->Format with Multiple Columns but I can't seem to format the column sizes that well. I also tried the Cross-Tab but that was even worse for my scenario.

I need something that looks like this.

Employee Name   Clock in Clock Out Clock in Clock out Clock in Clock out

Employee ABC     8:00 AM 12:30 PM 1:00 PM   3:30 PM 4:00 PM   6:30 PM

In my SQL DATA, it would read on separate lines such as.

Employee Name   Clock in Clock Out

Employee ABC    8:00 AM 12:30 PM
Employee ABC    1:00 PM 3:30 PM
Employee ABC    4:00 PM 6:30 PM

Any help or direction would be appreciated.

Thank you.
IP IP Logged
sharona
Senior Member
Senior Member
Avatar

Joined: 16 Oct 2008
Location: United States
Online Status: Offline
Posts: 255
Quote sharona Replybullet Posted: 12 May 2011 at 3:16am
you could create groups i gather by date and group by day
then place the clock in in the group then  insert a 2nd group and place the clock out next to it
then underlay
 
not sure but it may work
 
are you using a stored procedure as the dataset?
 
you can always create a case statement to create a column or use an update query to do the same
sharona
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 12 May 2011 at 3:27am
if there are a set number of clock in/out pairs, you could use shared variables accomplish the task, but if the number of pairs is unknown, or outside of the number that you created, this would lead to missed punches.
 
This is what I would do...
Lets make 5 sets of punches, just for fun, these would be reset in the group header (probably employee or employee/date)
shared datetimevar   in1 := '1/1/1900';
shared datetimevar out1 := '1/1/1900';
shared datetimevar   in2 := '1/1/1900';
shared datetimevar out2 := '1/1/1900';
shared datetimevar   in3 := '1/1/1900';
shared datetimevar out3 := '1/1/1900';
shared datetimevar   in4 := '1/1/1900';
shared datetimevar out4 := '1/1/1900';
shared datetimevar   in5 := '1/1/1900';
shared datetimevar out5 := '1/1/1900';
shared numbervar rowCount = 0;
 
in another formula for the detail section
shared datetimevar   in1 ;
shared datetimevar out1 ;
shared datetimevar   in2 ;
shared datetimevar out2 ;
shared datetimevar   in3 ;
shared datetimevar out3 ;
shared datetimevar   in4 ;
shared datetimevar out4;
shared datetimevar   in5;
shared datetimevar out5;
shared numbervar rowCount ;
 
rowCount := rowCount + 1;
if rowCount = 1 then(
  in1 := {table.timeIn};
  out1:= {table.timeOut};
);
if rowCount = 2 then(
  in2 := {table.timeIn};
  out2:= {table.timeOut};
);
repeat for other cases
"" // to hide the formula
 
 
then in the group footer, there would be lots of formulas, like:
shared datetimevar in1;
if in1 <> '1/1/1900' then
  toText(in1, "hh:mm:ss")
else
  ""
 
this way you can create variables and display them horizontally, having captured them from a vertical list
 
HTH
 
 
 
IP IP Logged
cmt.it.steve
Newbie
Newbie


Joined: 11 May 2011
Online Status: Offline
Posts: 3
Quote cmt.it.steve Replybullet Posted: 12 May 2011 at 6:13am
Thank you for your replies.

@Sharona
I currently have groups created. One group for employee name and a second group for dates. I was hoping that I could then somehow list the clock in/clock out times horizontally. The data is contained in an XML file that gets generated through another program. Could I make a case statement in Crystal Reports to create columns?

@lockwelle
I'm unfamiliar with the coding techniques in Crystal Report. I understand the actual code however I'm not sure how I would implement it. For example, I have read that I need to put formulas in the header, detail, and the footer. I have also read that I should suppress the section after I have put the formula in the section. I'm not quite sure if that is necessary or not. Does the name of the formulas matter at all? For example, if I created a formula for the header section and call it header_declaration and created another formula for the detail section and call it detail_implementation, do I need to explicitly connect the two formulas at all or does Crystal Report do all that for me because it is part of the same group? Then in the Footer section, you mentioned that I would need a lot of formulas. Does this mean that I would need a formula per clock in/clock out? Also, the amount of punches that you mentioned would be a maximum of 3 (3 sets of clock in/clock out) however, not all 3 are used. Many times only 1 set is used. Would that be a problem if I were to take this route?
IP IP Logged
sharona
Senior Member
Senior Member
Avatar

Joined: 16 Oct 2008
Location: United States
Online Status: Offline
Posts: 255
Quote sharona Replybullet Posted: 12 May 2011 at 7:25am
xml is a bit different. you insert the xml via a command file correct?
not sure if you can add a case statement to a command file using xml
did you create the xml dataset?
 
did you try to create a formula for clock in and clock out?
sharona
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 13 May 2011 at 11:08am
you can create a datasource as xml...really easy to do
 
the name of the formulas is immaterial.  CR executes the formula in whatever section to drop it in.  What 'matters' is the name of the variable.  No formal declaration is needed, whichever Shared xxxVar that CR sees first is the declaration, it defaults to 0 for numbers if they are not explicitly set...or reset as the case may be.
 
Actually each Punch in or out would have its own formula to display its own value (this way they line up all nicely).  As for punches that are not used, you could suppress them or display an empty string "", and nothing will be displayed, it's really the same as displaying fields, just you are treating your formula as a field.
 
As for suppression, it's not needed.  I rarely suppress a section just because there is a formula in it.  I tend to hide the formula by ending it with a "", since CR displays the last line in the formula.
 
Hope this clears up some of the confusion.  Variables and formulas make CR so much easier / more robust to deal with.
IP IP Logged
cmt.it.steve
Newbie
Newbie


Joined: 11 May 2011
Online Status: Offline
Posts: 3
Quote cmt.it.steve Replybullet Posted: 19 May 2011 at 12:36pm
Thank you for your response. I got the horizontal data to work correctly.

I now have another question on the same report.

On the timecard report that I am making, I need to create list out all the days in a month (from 1 - 31 at most) and have each clock in period on the adjacent line to the respected date.

Date    Day    In   Out
1          S        …
2          N          …
3          M          …
4          T          …
5          W          …
6          R          …
7          F          …
8          S        …
9          N        …
…

I currently have the Date and the Days listed out in the report using a formula to create the dates. The question that I have is the dataset that I have will have approx 5 days out of the week, typically from Monday to Friday, however, there are times when people work on the weekends, both Saturday and Sunday which means I must include those in the report. If I make an If statement that checks the clockindate with the date, is there a way I can make the data move to the next line or not do anything for that line? If I try an if statement to check, I’m not sure what to do if it is not that date. For example,

My dataset would have

1/6/2011    …
1/7/2011    …
1/10/2011    …

Because I don’t have any data for 1/8/2011 and 1/9/2011, I’m not sure how to “skip” that line.

I apologize if it sounds confusing.

Thank you.
IP IP Logged
CircleD
Senior Member
Senior Member
Avatar

Joined: 11 Mar 2011
Location: United States
Online Status: Offline
Posts: 251
Quote CircleD Replybullet Posted: 19 May 2011 at 5:10pm
If you end your If,Then with   else " "   it should skip over that day as that will be an empty string.
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum