Results 1 to 20 of 20

Thread: [RESOLVED] Help in Data Report

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2008
    Posts
    108

    Resolved [RESOLVED] Help in Data Report

    Is it possible that I can create a transaction receipt just by using data report? From the example that I've seen it seems that the report displays a list. I just need one row/record from the database (I'm using MS Access and SQL) containing the Payment No, Payment and payment type to create the receipt. Is it also possible that one report can use two different sets of database table? For example one textfield has a different datasource from another textfield.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Help in Data Report

    To you, it might be a "transaction receipt"

    To the software itself, it is nothing more than another report, so once you get the formatting correct, there is no reason it can't be used for your purpose.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 2008
    Posts
    108

    Re: Help in Data Report

    Yup that's what I'm asking if ever I could just select one record from the database to make it look like a receipt.

  4. #4
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Help in Data Report

    Yes, you can used different columns from different tables if that is what you want, you just have to INNER JOIN them.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  5. #5
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Help in Data Report

    This is an MSDN article on using DataReport, perhaps it should help.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  6. #6
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,515

    Re: Help in Data Report

    When you say "two different data sources", do you mean two different databases or two different tables in the same database? Big difference.

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Dec 2008
    Posts
    108

    Re: Help in Data Report

    Quote Originally Posted by wes4dbt
    When you say "two different data sources", do you mean two different databases or two different tables in the same database? Big difference.
    Two tables in one database.

    Quote Originally Posted by dee-u
    This is an MSDN article on using DataReport, perhaps it should help.
    Thanks for that, but what command am I supposed to use select one record from the database? I've used the code below in the command text but it displays nothing.

    Code:
    SELECT * FROM payment WHERE pono = 'Form1.Text1.Text'
    Last edited by Encoder; Jan 7th, 2009 at 07:32 PM.

  8. #8
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,515

    Re: Help in Data Report

    If your using an ADO recordset for the reports datasource then use something like this
    Code:
    select * from table1 inner join table2 on table1.paymentId=table2.paymentId where table1.paymentId='" & Text1.Text & "'"
    If your using a DataEnvironment for the datasource then check out this post
    http://www.vbforums.com/showthread.php?t=552148

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Dec 2008
    Posts
    108

    Re: Help in Data Report

    Where should I put those codes in the project?

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Dec 2008
    Posts
    108

    Re: Help in Data Report

    ^ What I mean is the code you mentioned on the other thread you gave me. Sorry for the misleading post, my head hurts.

    Code:
    deCropbyuser.Commands("Command1_grouping").Parameters("param1").Value = frmUrange!txtStart
    deCropbyuser.Commands("Command1_grouping").Parameters("param2").Value = frmUrange!txtEnd
            rptCropbyuser.Show vbModal

  11. #11
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,515

    Re: Help in Data Report

    If your using a Command Button to print the report then put it in the "click" event. It can be just about anywhere in your code. The DataEnvironment and DataReport are Public objects.

  12. #12

    Thread Starter
    Lively Member
    Join Date
    Dec 2008
    Posts
    108

    Re: Help in Data Report

    ^Okay I get it thanks. But what part in the added commands is this particular code (the ones in bold and underlined)?

    Code:
    deCropbyuser.Commands("Command1_grouping").Parameters("param1").Value = frmUrange!txtStart
    deCropbyuser.Commands("Command1_grouping").Parameters("param2").Value = frmUrange!txtEnd
            rptCropbyuser.Show vbModal
    Last edited by Encoder; Jan 9th, 2009 at 09:50 AM.

  13. #13
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,515

    Re: Help in Data Report

    If you look at the DataEnvironment attachment in the link with that code you will see "Command1 grouped using Command1_Grouping". Go to the properties, you'll see the SQL has 2 "?". Select the Parameters tab. The first "?" is "param1" and the second is "param2"

  14. #14

    Thread Starter
    Lively Member
    Join Date
    Dec 2008
    Posts
    108

    Re: Help in Data Report

    Is param1 and param2 constant?

  15. #15
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,515

    Re: Help in Data Report

    This code is setting the value of param1 and param2, it is located in the "click" event of a Command Button
    Code:
    deCropbyuser.Commands("Command1_grouping").Parameters("param1").Value = frmUrange!txtStart
    deCropbyuser.Commands("Command1_grouping").Parameters("param2").Value = frmUrange!txtEnd
     rptCropbyuser.Show vbModal
    You can name the parameters anything you want when you design the dataenvironment.

  16. #16

    Thread Starter
    Lively Member
    Join Date
    Dec 2008
    Posts
    108

    Re: Help in Data Report

    Quote Originally Posted by wes4dbt
    If you look at the DataEnvironment attachment in the link with that code you will see "Command1 grouped using Command1_Grouping". Go to the properties, you'll see the SQL has 2 "?". Select the Parameters tab. The first "?" is "param1" and the second is "param2"
    I missed that one, I didn't look through the Parameter tab until now. Anyway thanks for the help.

  17. #17

    Thread Starter
    Lively Member
    Join Date
    Dec 2008
    Posts
    108

    Re: [RESOLVED] Help in Data Report

    Alright I have another problem, I've used the code and it works but only in the first time. In the commands in the data environment I've inputted "SELECT * FROM payment WHERE ID = ?", named ? as param1. Then on the click eventI used this code
    Code:
    DataEnvironment1.Commands("payment").Parameters("param1").Value = frmPayment!txtPayNo                
    DataReport1.Show vbModal
    The datareport displays what I intended the first time (for example If the textbox has "1" in it displays the columns with ID "1" from the payment table, but when I click again and this time the textbox displays "2", the report still displays the columns with ID "1".

  18. #18
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,515

    Re: [RESOLVED] Help in Data Report

    You have to close the recordset or requery,

    Code:
    If deCropbyuser.rsCommand1_Grouping.State = adStateOpen Then
          deCropbyuser.rsCommand1_Grouping.Close
    End If
    Put this just before you set the param1 and run the report, I guess you could close the recordset right after you run the report.
    Last edited by wes4dbt; Jan 19th, 2009 at 01:26 PM.

  19. #19

    Thread Starter
    Lively Member
    Join Date
    Dec 2008
    Posts
    108

    Re: [RESOLVED] Help in Data Report

    ^ It works, however there's still a problem, cause my VB seems to be working strangely. Whenever I put a breakpoint right before the DataReport shows, the info I need displays on the DataReport. But if I clear the breakpoint (there's no breakpoint at all), the DataReport just displays blank. What seems to be the problem?

  20. #20
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,515

    Re: [RESOLVED] Help in Data Report

    I'd guess you are putting the data in a table just before you run the report. ACCESS has a delay before it writes the data. I found that closing the recordset and connection before running the report helps.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width