|
-
Oct 19th, 2006, 02:42 AM
#1
Thread Starter
New Member
[RESOLVED] Need help with datareport / dataenvironment
Hi everyone,
I have a form that displays customers, in a combobox. You select one and click a command button.
it then generates another combobox with the month usage reports. you select a month to view and click a command button.
This brings up the datareport with the data for that time period.
This all works.
if you then select another month and click the command button it will display the same info again.
I have used debug.print, gotta love it, and it shows that the sql is different. But the report is still the same. this is how i change the command text.
VB Code:
DataEnvironment1.Commands.Item("Command2").CommandText = strsql
DataEnvironment1.Commands.Item("Command2").Execute strsql
why doesn't it work.
-
Oct 19th, 2006, 02:48 AM
#2
Re: Need help with datareport / dataenvironment
The datareport data-bound at design time? Try refreshing the data report; datareport1.refresh
-
Oct 19th, 2006, 02:53 AM
#3
Thread Starter
New Member
Re: Need help with datareport / dataenvironment
I have tried that, no luck. When I load the form and choose a month it works properly, its just when you try and select another month that is doesn't refresh.
VB Code:
Dim strsql As String
strsql = "SELECT DISTINCT * FROM rpt_tsheet WHERE t_empnum= '" & frmTSheetSelect.cmbDomestic.Tag & "' AND t_id =" & frmTSheetSelect.cmbDomestic1.Tag & ""
Debug.Print "CHECK " & strsql
DataEnvironment1.Commands.Item("Command2").CommandText = strsql
DataEnvironment1.Commands.Item("Command2").Execute strsql
rptDomestic.Refresh
That is all my code on the report. Yes it is data bound.
-
Oct 19th, 2006, 03:11 AM
#4
Re: Need help with datareport / dataenvironment
Try resetting the datasource property of the report.
-
Oct 19th, 2006, 03:17 AM
#5
Thread Starter
New Member
Re: Need help with datareport / dataenvironment
when i try this
VB Code:
rptDomestic.DataSource = DataEnvironment1
it tells me 'Method or data member not found'
-
Oct 19th, 2006, 03:23 AM
#6
Re: Need help with datareport / dataenvironment
You need to set it to an ADO recordset. Try this
Set rptDomestic.DataSource = DataEnvironment1.Commands.Item("Command2").Execute(strsql)
If that doesn;t work then we'll use non-bound methods
-
Oct 19th, 2006, 03:26 AM
#7
Re: Need help with datareport / dataenvironment
Or maybe you could zip it up along with DB (is the db large?)
Hard to come up with a solution cause we have no code we can refer to... and the databound properties only you can see their values.
-
Oct 19th, 2006, 03:33 AM
#8
Thread Starter
New Member
Re: Need help with datareport / dataenvironment
Thanks for your help so far, unfortunately I can't attach the code or the db - I could get into trouble :-(
-
Oct 19th, 2006, 04:16 AM
#9
Re: Need help with datareport / dataenvironment
I usually don't use the dataenvironment cause its just a graphical wrapper for ado hence there's additional memory use. You can do something like this at run time.
VB Code:
Public Sub ShowDomesticReport()
'Dim conn As New ADODB.Connection 'assume already open
Dim rs As ADODB.Recordset
Dim rpt As New rptDomestic
Dim strSQL as String
strSQL = "SELECT DISTINCT * FROM rpt_tsheet WHERE t_empnum= '" & _
frmTSheetSelect.cmbDomestic.Tag & "' AND t_id =" & _
frmTSheetSelect.cmbDomestic1.Tag & ""
On Error Goto Err_Handler
Set rs = conn.Execute strsql
'Header section labels and report caption
With rpt.Section("Header")
.Controls("lblCompany").Caption = Form1.lblCompany.Caption
.Controls("lblAdd1").Caption = Form1.txtAddress1.Text
.Controls("lblAdd2").Caption = Form1.txtAddress2.Text
End With
rpt.Caption = "Domestic Report"
'Set datasource and bind recordset fields.
'Update fields and datareport control names to those you use
Set rpt.DataSource = rs
With rpt.Section("Details")
.Controls("txtQuantity").DataField = "Quantity" 'where quantity is a field in the recordset
.Controls("txtUnit").DataField = "Unit"
.Controls("txtParticulars").DataField = "Particulars"
.Controls("txtUnitPrice").DataField = "Unit Price"
.Controls("txtAmount").DataField = "Amount"
End With
rpt.Show vbModal
rs.Close
Unload rpt
Set rs = Nothing
Set rpt = Nothing
Exit Sub
Err_Handler:
'your error handling code
End Sub
Last edited by leinad31; Oct 19th, 2006 at 04:40 AM.
-
Oct 19th, 2006, 05:28 AM
#10
Thread Starter
New Member
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
|