|
-
Jun 11th, 2000, 08:33 PM
#5
Thread Starter
Addicted Member
problem is...
I have a dataEnviporment and a report. I change the command.Text in my dataEnviorment to an SQL string that has user imput added, then I open the report object.
All the requested info comes up the first time the user uses the report, but if they generate a new difrent report the old data stays and the new data is no where to be seen. I had this working exept there was no custom user input. they could generate a report and if they add new data to the database that should be in report it would come up. when they reopened the report.
this the code that changes the command.text
Private Sub flbGen_Click()
If txtYear.Text = " " Or txtYear.Text = "" Then
MsgBox "Please enter the year you wish to Search....", , "User Error.."
Exit Sub
End If
Dim nReport As New Report
'I am at this point loading a new instance of the report object
'rebinding it to the dataEnviorment
'refreshing it(which is pointless by the way)
'then showing it with the new SQL string load
'the report will generate the first time but will not redraw the data even when
'a unused instance is opened
Select Case lstMonth.Text
Case "1 - January"
ClientDataEnvir.Commands("MonthlyReport").CommandText = "SELECT ClientData.Name, ClientData.Address, ClientData.CustomerType, ClientData.LastWork, ClientData.NextScheduled, ClientData.JobStatus, DateDiff('d',Now(),[clientdata].[nextscheduled]) AS Expr1 From ClientData Where (((DatePart('m', [ClientData].[NEXTSCHEDULED])) Like " & "'" & "1" & "'" & ") And ((DatePart('yyyy', [ClientData].[NEXTSCHEDULED])) Like " & "'" & txtYear.Text & "'" & "))ORDER BY ClientData.Name;"
Set nReport.DataSource = ClientDataEnvir
nReport.DataMember = "MonthlyReport"
nReport.Refresh
nReport.Show
Case "2 - February"
ClientDataEnvir.Commands("MonthlyReport").CommandText = "SELECT ClientData.Name, ClientData.Address, ClientData.CustomerType, ClientData.LastWork, ClientData.NextScheduled, ClientData.JobStatus, DateDiff('d',Now(),[clientdata].[nextscheduled]) AS Expr1 From ClientData Where (((DatePart('m', [ClientData].[NEXTSCHEDULED])) Like " & "'" & "2" & "'" & ") And ((DatePart('yyyy', [ClientData].[NEXTSCHEDULED])) Like " & "'" & txtYear.Text & "'" & "))ORDER BY ClientData.Name;"
Set nReport.DataSource = ClientDataEnvir
nReport.DataMember = "MonthlyReport"
nReport.Show
Case "3 - March"
ClientDataEnvir.Commands("MonthlyReport").CommandText = "SELECT ClientData.Name, ClientData.Address, ClientData.CustomerType, ClientData.LastWork, ClientData.NextScheduled, ClientData.JobStatus, DateDiff('d',Now(),[clientdata].[nextscheduled]) AS Expr1 From ClientData Where (((DatePart('m', [ClientData].[NEXTSCHEDULED])) Like " & "'" & "3" & "'" & ") And ((DatePart('yyyy', [ClientData].[NEXTSCHEDULED])) Like " & "'" & txtYear.Text & "'" & "))ORDER BY ClientData.Name;"
Set nReport.DataSource = ClientDataEnvir
nReport.DataMember = "MonthlyReport"
nReport.Refresh
nReport.Show
Case "4 - April"
ClientDataEnvir.Commands("MonthlyReport").CommandText = "SELECT ClientData.Name, ClientData.Address, ClientData.CustomerType, ClientData.LastWork, ClientData.NextScheduled, ClientData.JobStatus, DateDiff('d',Now(),[clientdata].[nextscheduled]) AS Expr1 From ClientData Where (((DatePart('m', [ClientData].[NEXTSCHEDULED])) Like " & "'" & "4" & "'" & ") And ((DatePart('yyyy', [ClientData].[NEXTSCHEDULED])) Like " & "'" & txtYear.Text & "'" & "))ORDER BY ClientData.Name;"
Set nReport.DataSource = ClientDataEnvir
nReport.DataMember = "MonthlyReport"
nReport.Refresh
nReport.Show
Case "5 - May"
ClientDataEnvir.Commands("MonthlyReport").CommandText = "SELECT ClientData.Name, ClientData.Address, ClientData.CustomerType, ClientData.LastWork, ClientData.NextScheduled, ClientData.JobStatus, DateDiff('d',Now(),[clientdata].[nextscheduled]) AS Expr1 From ClientData Where (((DatePart('m', [ClientData].[NEXTSCHEDULED])) Like " & "'" & "5" & "'" & ") And ((DatePart('yyyy', [ClientData].[NEXTSCHEDULED])) Like " & "'" & txtYear.Text & "'" & "))ORDER BY ClientData.Name;"
Set nReport.DataSource = ClientDataEnvir
nReport.DataMember = "MonthlyReport"
nReport.Refresh
nReport.Show
Case "6 - June"
ClientDataEnvir.Commands("MonthlyReport").CommandText = "SELECT ClientData.Name, ClientData.Address, ClientData.CustomerType, ClientData.LastWork, ClientData.NextScheduled, ClientData.JobStatus, DateDiff('d',Now(),[clientdata].[nextscheduled]) AS Expr1 From ClientData Where (((DatePart('m', [ClientData].[NEXTSCHEDULED])) Like " & "'" & "6" & "'" & ") And ((DatePart('yyyy', [ClientData].[NEXTSCHEDULED])) Like " & "'" & txtYear.Text & "'" & "))ORDER BY ClientData.Name;"
Set nReport.DataSource = ClientDataEnvir
nReport.DataMember = "MonthlyReport"
nReport.Refresh
nReport.Show
Case "7 - July"
ClientDataEnvir.Commands("MonthlyReport").CommandText = "SELECT ClientData.Name, ClientData.Address, ClientData.CustomerType, ClientData.LastWork, ClientData.NextScheduled, ClientData.JobStatus, DateDiff('d',Now(),[clientdata].[nextscheduled]) AS Expr1 From ClientData Where (((DatePart('m', [ClientData].[NEXTSCHEDULED])) Like " & "'" & "7" & "'" & ") And ((DatePart('yyyy', [ClientData].[NEXTSCHEDULED])) Like " & "'" & txtYear.Text & "'" & "))ORDER BY ClientData.Name;"
Set nReport.DataSource = ClientDataEnvir
nReport.DataMember = "MonthlyReport"
nReport.Refresh
nReport.Show
Case "8 - August"
ClientDataEnvir.Commands("MonthlyReport").CommandText = "SELECT ClientData.Name, ClientData.Address, ClientData.CustomerType, ClientData.LastWork, ClientData.NextScheduled, ClientData.JobStatus, DateDiff('d',Now(),[clientdata].[nextscheduled]) AS Expr1 From ClientData Where (((DatePart('m', [ClientData].[NEXTSCHEDULED])) Like " & "'" & "8" & "'" & ") And ((DatePart('yyyy', [ClientData].[NEXTSCHEDULED])) Like " & "'" & txtYear.Text & "'" & "))ORDER BY ClientData.Name;"
Set nReport.DataSource = ClientDataEnvir
nReport.DataMember = "MonthlyReport"
nReport.Refresh
nReport.Show
Case "9 - September"
ClientDataEnvir.Commands("MonthlyReport").CommandText = "SELECT ClientData.Name, ClientData.Address, ClientData.CustomerType, ClientData.LastWork, ClientData.NextScheduled, ClientData.JobStatus, DateDiff('d',Now(),[clientdata].[nextscheduled]) AS Expr1 From ClientData Where (((DatePart('m', [ClientData].[NEXTSCHEDULED])) Like " & "'" & "9" & "'" & ") And ((DatePart('yyyy', [ClientData].[NEXTSCHEDULED])) Like " & "'" & txtYear.Text & "'" & "))ORDER BY ClientData.Name;"
Set nReport.DataSource = ClientDataEnvir
nReport.DataMember = "MonthlyReport"
nReport.Refresh
nReport.Show
Case "10 - October"
ClientDataEnvir.Commands("MonthlyReport").CommandText = "SELECT ClientData.Name, ClientData.Address, ClientData.CustomerType, ClientData.LastWork, ClientData.NextScheduled, ClientData.JobStatus, DateDiff('d',Now(),[clientdata].[nextscheduled]) AS Expr1 From ClientData Where (((DatePart('m', [ClientData].[NEXTSCHEDULED])) Like " & "'" & "10" & "'" & ") And ((DatePart('yyyy', [ClientData].[NEXTSCHEDULED])) Like " & "'" & txtYear.Text & "'" & "))ORDER BY ClientData.Name;"
Set nReport.DataSource = ClientDataEnvir
nReport.DataMember = "MonthlyReport"
nReport.Refresh
nReport.Show
Case "11 - November"
ClientDataEnvir.Commands("MonthlyReport").CommandText = "SELECT ClientData.Name, ClientData.Address, ClientData.CustomerType, ClientData.LastWork, ClientData.NextScheduled, ClientData.JobStatus, DateDiff('d',Now(),[clientdata].[nextscheduled]) AS Expr1 From ClientData Where (((DatePart('m', [ClientData].[NEXTSCHEDULED])) Like " & "'" & "11" & "'" & ") And ((DatePart('yyyy', [ClientData].[NEXTSCHEDULED])) Like " & "'" & txtYear.Text & "'" & "))ORDER BY ClientData.Name;"
Set nReport.DataSource = ClientDataEnvir
nReport.DataMember = "MonthlyReport"
nReport.Refresh
nReport.Show
Case "12 - December"
ClientDataEnvir.Commands("MonthlyReport").CommandText = "SELECT ClientData.Name, ClientData.Address, ClientData.CustomerType, ClientData.LastWork, ClientData.NextScheduled, ClientData.JobStatus, DateDiff('d',Now(),[clientdata].[nextscheduled]) AS Expr1 From ClientData Where (((DatePart('m', [ClientData].[NEXTSCHEDULED])) Like " & "'" & "12" & "'" & ") And ((DatePart('yyyy', [ClientData].[NEXTSCHEDULED])) Like " & "'" & txtYear.Text & "'" & "))ORDER BY ClientData.Name;"
Set nReport.DataSource = ClientDataEnvir
nReport.DataMember = "MonthlyReport"
nReport.Refresh
nReport.Show
End Select
End Sub
I don't think the reBinding to the datasource abd datamemeber is necisary I had add that to see if maybe the report wasn't recieving the new command string...
also when the report loads I have it reruery in
Report_Activate (this is a really cranky thing to do)
Thankz
Zan
Magiaus
Visual Basic 6.0 SP5
Visual C++ 6.0 SP5
The only sovereign you can allow to rule you is reason.
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
|