How to display the last inserted records in crystal report

  • (2 Pages)
  • +
  • 1
  • 2

20 Replies - 6602 Views - Last Post: 28 March 2013 - 06:23 AM Rate Topic: -----

#1 Adqusit  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 152
  • Joined: 02-March 13

How to display the last inserted records in crystal report

Posted 19 March 2013 - 06:30 AM

Hi. I don't know that where to post this thread, hence i am posting here. If wrong so please guide me.

Hi. I have a Sales form. I want that when the user sales 1 or more than 1 products to the customer and after pressing the submit button, so the record saves in DataBase and Crystal report of those last inserted records is created. In simple words i want to create a simple Crystal Report, on which i want to show the last inserted records from DataBase.

Please guide me that how to this?

Is This A Good Question/Topic? 0
  • +

Replies To: How to display the last inserted records in crystal report

#2 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1053
  • View blog
  • Posts: 4,080
  • Joined: 02-July 08

Re: How to display the last inserted records in crystal report

Posted 19 March 2013 - 09:36 PM

Possibly with the suppression expression on the details section place Not OnLastRecord in the formula editor. To get this you right click on the details section on the left side and select Section Expert and click on the X2 button(expression button) for the suppression choice. It basically says if this is not the last record suppress it I don't have a way to test this except at work - which would be a few days before I get back there. Just an idea.

This post has been edited by _HAWK_: 19 March 2013 - 09:38 PM

Was This Post Helpful? 0
  • +
  • -

#3 Adqusit  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 152
  • Joined: 02-March 13

Re: How to display the last inserted records in crystal report

Posted 20 March 2013 - 05:52 AM

Hooo, Hey HAWK, I didn't not understand any word in this reply, sorry to say. I couldn't even understand that what is this? :smartass:
Was This Post Helpful? 0
  • +
  • -

#4 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1605
  • View blog
  • Posts: 5,162
  • Joined: 25-September 09

Re: How to display the last inserted records in crystal report

Posted 20 March 2013 - 08:08 AM

I've not worked with Crystal Reports for a few years, but if you understand how the report layout works, you should be able to read what _HAWK_ suggested, follow along and see the result of his solution.

_HAWK_'s solution is how I first understood your question. But but now as I re-read it, it doesn't seem to be what you want. Is there a value somewhere in those rows that you can use in the formula to suppress all but those rows? His solution will suppress everything except the last row. But you may have more than one "Group" of rows that are the last entry for that data. How do you differentiate those rows from all the other rows in the table?

With that information, you can suppress based off of that criteria.

This post has been edited by CharlieMay: 20 March 2013 - 08:11 AM

Was This Post Helpful? 0
  • +
  • -

#5 Adqusit  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 152
  • Joined: 02-March 13

Re: How to display the last inserted records in crystal report

Posted 20 March 2013 - 09:53 AM

Hi. I have the following fields in my Table.

Sale_ID, Prod_ID, Sale_Prod_Qty, Sale_Prod_PriceOfOne, Sale_Prod_PriceOfall, Sale_Date

where Sale_ID is primary key and Prod_ID is a foreign key (not a perfect foreign key) actually the value from ProdInfo table is just loading on form (but its a point, just i want to mention).

If Hawk, wants all records to be suppressed so only last record will be remaining, which does not fulfill my need. Oftenly, i need more than 1 records to be retrieved, so in such case, Hawk way of supressing the entire rows, except the last one won't work, as i think.
Was This Post Helpful? 0
  • +
  • -

#6 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1605
  • View blog
  • Posts: 5,162
  • Joined: 25-September 09

Re: How to display the last inserted records in crystal report

Posted 20 March 2013 - 10:09 AM

Yea, probably not, because he understood your question the same way I originally did.
so now that we've cleared that up, was you going to answer my question on how YOU can determine those rows you're wanting? Because you're probably going to have to pass a SelectionFormula to the report based on that criteria.
Was This Post Helpful? 0
  • +
  • -

#7 Adqusit  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 152
  • Joined: 02-March 13

Re: How to display the last inserted records in crystal report

Posted 20 March 2013 - 06:15 PM

@ Charlier,

Okay, so what criteria i will pass to the Selection Formula?
Was This Post Helpful? 0
  • +
  • -

#8 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1605
  • View blog
  • Posts: 5,162
  • Joined: 25-September 09

Re: How to display the last inserted records in crystal report

Posted 20 March 2013 - 06:19 PM

The criteria that makes the last item(s) entered unique to all the others in the database. Again, that is the question I'm asking, If you were to open your table could you determine the rows that would be listed in the report without knowing how many rows the user entered last?

Until you can supply that information, it will be hard for us to determine any forumla for selecting them.
Was This Post Helpful? 0
  • +
  • -

#9 Adqusit  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 152
  • Joined: 02-March 13

Re: How to display the last inserted records in crystal report

Posted 20 March 2013 - 06:46 PM

NO Charlier. This is determination is my question, exactly.
How do i determine that what number of rows, will be listed on crystal report. This determination will be actually made on the number of records, will be inserted by insert query. This can't be determined, because lets suppose if the user sales 4 items to a customer and then he sells 10 items to another customer and then 3 to another, so the number of items he will sale, the same number of items will be displayed on report. I think its a bit clear now.
Was This Post Helpful? 0
  • +
  • -

#10 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1605
  • View blog
  • Posts: 5,162
  • Joined: 25-September 09

Re: How to display the last inserted records in crystal report

Posted 20 March 2013 - 06:58 PM

It's clear, but unless you come up with a way to where you can tag those rows as a group of rows that should be printed to the report. You are going to have a hard time. Sounds like you're going to have to do something in your database to help you in that determination.

Let me pose this question. Let's say that you could do it right now and you sent the report to the printer and went on to enter a new sale. Now let's say that printer malfunctioned and that report never printed. How would you reprint that report?

If you can't answer that question, then you need to rethink your table design so that you don't lose that grouping.

I feel there is a slight language barrier here but the fact that you can't tell me based on what someone did in a session screams that there is something lost in the record storage solution you currently have in place. This could be nothing more than another column that holds the same timestamp of the transaction in all the fields. Or more easily managed, a sales order number. Then you could filter on all rows that have that unique sales order number.

This post has been edited by CharlieMay: 20 March 2013 - 07:02 PM

Was This Post Helpful? 0
  • +
  • -

#11 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1053
  • View blog
  • Posts: 4,080
  • Joined: 02-July 08

Re: How to display the last inserted records in crystal report

Posted 20 March 2013 - 07:19 PM

Quote

NO Charlier.


How do you spell his username wrong - it's right there, and you did it twice - some respect here ok!

So it sounds like you want a group of records by a client. Are you able to make a separate query to get just a client number and then pass that to the report with a parameter field? That I think would solve your problem, but you will have to figure out what your criteria is so you know what that query will look like.
Was This Post Helpful? 0
  • +
  • -

#12 Adqusit  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 152
  • Joined: 02-March 13

Re: How to display the last inserted records in crystal report

Posted 21 March 2013 - 05:57 AM

@ Charlie and HAWK.

I think its my deficiency that i am not understanding the question properly, or may be my wordings are not expressing the idea, exactly what I have in my mind.

I have a DGV, on SaleForm, by which user can insert more than 1 records with single insert statement right. Now i want that when the insertion is completed and data is saved so a print of last saled product is printed for the customer, right.

Now i re-Studied all the above mentioned answers, specially 4, 5, 6, 10 and 11. You were wanting me to have a uniqueness in every group of new records that will be inserted from DGV. So i found the solution for this uniqueness. I have a Sale_Date column in my Table. Now what i need to display in my Crystal report is last inserted number of records whether 1 or more. So If i put the query that Retrieve those records, which have the latest time second, because whenever single or more than 1 records will be inserted, so their time second will be same and thus, this same second will make the uniqueness and i will retrieve all those records which will have the same time second.

I hope that my weak english, will put my idea clearly before you.

Now Please guide me that whether is it a right way?

This post has been edited by Adqusit: 21 March 2013 - 06:04 AM

Was This Post Helpful? 0
  • +
  • -

#13 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1605
  • View blog
  • Posts: 5,162
  • Joined: 25-September 09

Re: How to display the last inserted records in crystal report

Posted 21 March 2013 - 06:15 AM

Adqusit are you using a commandbuilder to insert the rows?
Can you post the code where you're saving the information to the database? I think I have a better understanding from your last post.
Was This Post Helpful? 0
  • +
  • -

#14 Adqusit  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 152
  • Joined: 02-March 13

Re: How to display the last inserted records in crystal report

Posted 21 March 2013 - 06:35 AM

Hi Charlie. I would be glad if you will visit this link.

multiple record insertion with single insert statement

Hope this will help us more.
Was This Post Helpful? 0
  • +
  • -

#15 Adqusit  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 152
  • Joined: 02-March 13

Re: How to display the last inserted records in crystal report

Posted 21 March 2013 - 08:14 AM

Am I right with post # 12?
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2