|
-
Dec 28th, 2008, 04:10 AM
#1
Thread Starter
Lively Member
[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.
-
Dec 29th, 2008, 07:28 AM
#2
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.
-
Dec 29th, 2008, 08:19 AM
#3
Thread Starter
Lively Member
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.
-
Jan 3rd, 2009, 07:16 AM
#4
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.
-
Jan 5th, 2009, 09:51 AM
#5
Re: Help in Data Report
This is an MSDN article on using DataReport, perhaps it should help.
-
Jan 5th, 2009, 02:52 PM
#6
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.
-
Jan 7th, 2009, 07:25 PM
#7
Thread Starter
Lively Member
Re: Help in Data Report
 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.
 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.
-
Jan 7th, 2009, 08:14 PM
#8
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
-
Jan 7th, 2009, 08:38 PM
#9
Thread Starter
Lively Member
Re: Help in Data Report
Where should I put those codes in the project?
-
Jan 8th, 2009, 01:34 AM
#10
Thread Starter
Lively Member
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
-
Jan 8th, 2009, 10:08 PM
#11
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.
-
Jan 9th, 2009, 09:46 AM
#12
Thread Starter
Lively Member
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.
-
Jan 9th, 2009, 03:04 PM
#13
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"
-
Jan 10th, 2009, 11:22 AM
#14
Thread Starter
Lively Member
Re: Help in Data Report
Is param1 and param2 constant?
-
Jan 10th, 2009, 01:22 PM
#15
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.
-
Jan 13th, 2009, 08:23 AM
#16
Thread Starter
Lively Member
Re: Help in Data Report
 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.
-
Jan 19th, 2009, 01:02 AM
#17
Thread Starter
Lively Member
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".
-
Jan 19th, 2009, 01:18 PM
#18
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.
-
Jan 20th, 2009, 10:04 AM
#19
Thread Starter
Lively Member
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?
-
Jan 20th, 2009, 11:59 AM
#20
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|