We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,577 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Vb6 Data Report Repeatedly Shows Previous Report

Hi, I am a new member in this site. I am also just learning VB6. I made some progress in programming a report generator for my farm. However, after having designed a report using Data Report designer, I keep getting the same result or reports repeatedly although I have changed some parameters already. There's a need to click on the command button twice or reprocess the report twice just to get the desired data. Otherwise, old data on the reports remains which was actually the result of previous report processing. There seems to be a cache that keeps throwing the same data repeatedly although another recordsets of data have already been saved in the source table. I use Data Environment as data source for my report, Data Access Object for my forms and MS Access as database repository. Thanks.

10
Contributors
20
Replies
4 Years
Discussion Span
1 Year Ago
Last Updated
24
Views
Question
Answered
genie_ps
Newbie Poster
8 posts since Aug 2007
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Hi,

Before showing the report just Refresh it..:

DataReport1.Refresh
DataReport1.Show

Regards
Veena

QVeen72
Veteran Poster
1,017 posts since Nov 2006
Reputation Points: 118
Solved Threads: 164
Skill Endorsements: 5

Veena, thanks for the prompt reply. But, I already tried that and no success.

genie_ps
Newbie Poster
8 posts since Aug 2007
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Hi,

u can try this :

dataenv.Command1.Open
dataenv.Command1.Requery
DataReport1.Refresh
DataReport1.Show

Change the dataenv and command names..

Regards
Veena

QVeen72
Veteran Poster
1,017 posts since Nov 2006
Reputation Points: 118
Solved Threads: 164
Skill Endorsements: 5

Veena, thanks again. Tried that too, still no luck.

genie_ps
Newbie Poster
8 posts since Aug 2007
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Hi,

TryThis

Regards
Veena

QVeen72
Veteran Poster
1,017 posts since Nov 2006
Reputation Points: 118
Solved Threads: 164
Skill Endorsements: 5

I don't know if you found a solution but I fixed this by setting the Report Data Source to nothing and then assigning it again to the Data Environment like this:

Set DataReport1.DataSource = Nothing
Set DataReport1.DataSource = DataEnvironment1

Do this before doing anything and that should fix the problem.

Rich0001
Newbie Poster
3 posts since Aug 2007
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

Rich, Thanks for your reply. I just tried it. Didn't work for me. I fetch a set of data records that could fill up to 7 columnar pages (e.g. feed requirements of a huge number of sows. very important for us farmers to forecast budgeting and raw materials). I think the size of the data being generated is pushing MS access or MS Jet4.0 provider to the limit. (not sure). I tried for the past few days to do all sorts of initializing the data environment, tables and data object but causing another error "failing to get row sets" (whatever). In the meantime, I am just contented with clicking the command button one more time as if refreshing the displayed report the 2nd time. Hey, that is what is available in Crystal Reports but unfortunately it's not available in my town as yet. At least, Im happy enough for now clicking my Ok button twice. Really appreciate your concern to newbies like me.

I don't know if you found a solution but I fixed this by setting the Report Data Source to nothing and then assigning it again to the Data Environment like this:

Set DataReport1.DataSource = Nothing
Set DataReport1.DataSource = DataEnvironment1

Do this before doing anything and that should fix the problem.

genie_ps
Newbie Poster
8 posts since Aug 2007
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Maybe somehow when you show the report, it's not updated yet, maybe it gets only updated after you click the ok(or whatever). If you send your code, someone might be able to catch your problem.

plusplus
Posting Whiz in Training
207 posts since Jul 2007
Reputation Points: 10
Solved Threads: 16
Skill Endorsements: 0

Here is that part of the code where I show my datareport1:

Private Sub cmdOk_Click()
'========================
Dim nYear As Integer

nYear = nVal(cmbFromYear.Text)
isDiscounted = chkDiscounted.Value
isSumReport = chkSumReport.Value

dStartDate = cmbFromMonth.Text & " 01, " & cmbFromYear.Text
dStartDate = Format(dStartDate, "MM/dd/YYYY")       
dEndDate = cmbEndMonth.Text & " 28, " & cmbEndYear.Text   'part of determining
dEndDate = Format(dEndDate, "MM/dd/YYYY")                        'last date of the month.
dEndDate = xLastDay(dEndDate)                                           'Ending date to report

'Check correctnext of month entered
If Trim(cmbFromMonth.Text) = "" Or Not MonthNameOk(cmbFromMonth.Text) Then
     MsgBox "Enter a proper starting month name! ", vbExclamation, "Wrong entry"
     cmbFromMonth.SetFocus
     Exit Sub
End If

If Trim(cmbEndMonth.Text) = "" Or Not MonthNameOk(cmbEndMonth.Text) Then
     MsgBox "Enter a proper ending month name! ", vbExclamation, "Wrong entry"
     cmbEndMonth.SetFocus
     Exit Sub
End If

If cmbEndMonth.ListIndex < cmbFromMonth.ListIndex And _
       nVal(cmbEndYear.Text) <= nVal(cmbFromYear.Text) Then
       MsgBox "Starting month cannot be greater than ending month!", vbExclamation, "Wrong entry"
       Exit Sub
End If

'Check correctness of year number entered.
If nVal(cmbFromYear.Text) < Year(Date) Then
     MsgBox "Enter a proper starting year!", vbExclamation, "Wrong entry"
     Exit Sub
End If

If nVal(cmbEndYear.Text) < Year(Date) Then
     MsgBox "Enter a proper ending year!", vbExclamation, "Wrong entry"
     Exit Sub
End If

If nVal(cmbEndYear.Text) < nVal(cmbFromYear.Text) Then
     MsgBox "Starting year cannot be later than ending year!", vbExclamation, "Wrong entry"
     Exit Sub
End If

Me.MousePointer = vbHourglass

'Clean report file or RepoDetails table -> RepoDetails

With dtaRepoDetails.Recordset
    If .RecordCount <> 0 Then
        .MoveFirst
    End If
    While .EOF = False
          .Delete             'Delete all records used by       
          .MoveNext        'previous reporting.  This DAO table   
    Wend                     'is used to contain all fetch data
End With                     'prior to reporting

StoreReportDetails       'Save all data on a daily basis and save to REPODETAILS table

StoreReportWeekSummary    'Summarizes data on a wkly basis and save REPOSUMMARY

Load dtaEnvPigs     'Environment using MSjet 4.0 OLE provider with SQL command:
                            '  SELECT  YearNr, monthnr, weeknr, tagnr, PigAge, pigtype,
                            '          feedcode, feedname,heads, eachmealkg, totalcost,
                            '          totalkg, bags FROM REPOSUMMARY

With dtaEnvPigs
     If .RepoSummary.State <> 0 Then
          dtaEnvPigs.RepoSummary.Close  'Close the environment after loading
    End If                                              'hoping the close,open procedure will[/COLOR]
End With                                              'update the datareport1[/COLOR]

If Not isSumReport Then                   'Two reports use this SUB    
    DataReport1.LeftMargin = 200
    DataReport1.ReportWidth = 8865
    DataReport1.Width = 9100

    DataReport1.Refresh
    If DataReport1.Visible = False Then DataReport1.Show 1

Else
    DataReport4.LeftMargin = 200
    DataReport4.ReportWidth = 8865
    DataReport4.Width = 9100

    DataReport4.Refresh
    If DataReport4.Visible = False Then DataReport4.Show

End If
Unload dtaEnvPigs
Me.MousePointer = vbNormal
dtaRepoSum.Refresh
End Sub

Rich, Thanks for your reply. I just tried it. Didn't work for me. I fetch a set of data records that could fill up to 7 columnar pages (e.g. feed requirements of a huge number of sows. very important for us farmers to forecast budgeting and raw materials). I think the size of the data being generated is pushing MS access or MS Jet4.0 provider to the limit. (not sure). I tried for the past few days to do all sorts of initializing the data environment, tables and data object but causing another error "failing to get row sets" (whatever). In the meantime, I am just contented with clicking the command button one more time as if refreshing the displayed report the 2nd time. Hey, that is what is available in Crystal Reports but unfortunately it's not available in my town as yet. At least, Im happy enough for now clicking my Ok button twice. Really appreciate your concern to newbies like me.

genie_ps
Newbie Poster
8 posts since Aug 2007
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

My bad, I have tried to cut and paste but I can't get the right formatting of my code on this message box.

genie_ps
Newbie Poster
8 posts since Aug 2007
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

After
.delete
try to put
.update

plusplus
Posting Whiz in Training
207 posts since Jul 2007
Reputation Points: 10
Solved Threads: 16
Skill Endorsements: 0

plusplus,

Thanks for the reply. It didn't work but I caught the idea that the data environment which somehow does the caching of data needs to be updated.

I have been fiddling with the data outside the application using MS Access/VB6 Addins - Visual Data Manager directly. And even reset my PC or manually deletes the records in the table being pointed by the data environment, still the old report data gets retained.

After few days of playing around with all the properties of the data environment, the BEGIN TRANS, COMMIT TRANS and putting a PAUSE using a MSGBOX did the work:

---------------------------------------------------------


'*** Save all data on a daily basis and save to REPODETAILS table
StoreReportDetails dStartDate, dEndDate

'Summarizes data on a weekly basis and save to a REPOSUMMARY table.
StoreReportWeekSummary
'*** Environment using MSjet 4.0 OLE provider with
' SQL command:
' SELECT YearNr, monthnr, weeknr, tagnr, PigAge, pigtype,
' feedcode, feedname,heads, eachmealkg, totalcost,
' totalkg, bags FROM REPOSUMMARY
'------------------------------------------------------

Load dtaEnvPigs


With dtaEnvPigs


'*** Open the dta environment, to prepare begintrans
If .RepoSummary.State = 0 Then .RepoSummary.Open
End If

'*** Force saving of data by committing transactions

dtaEnvPigs.RepoSummary.BeginTrans
dtaEnvPigs.RepoSummary.CommitTrans

'*** Close the environment after loading***
dtaEnvPigs.RepoSummary.Close

'*** Give the provider sufficient delay time to commit trans.
If MsgBox("Press Ok to continue.", vbOKCancel, "Options") = vbCancel Then Exit Sub
End If End With

'***Two reports use this SUB, if isSumReport is true, DataReport1 gets printed.***

If Not isSumReport Then
DataReport1.LeftMargin = 200
DataReport1.ReportWidth = 8865
DataReport1.Width = 9100
DataReport1.Title = IIf(isDiscounted, "Discounted", " ")

If DataReport1.Visible = False Then
DataReport1.Show 1
Else
DataReport4.LeftMargin = 200
DataReport4.ReportWidth = 8865
DataReport4.Width = 9100

If DataReport4.Visible = False Then DataReport4.ShowEnd If

'*** I don't need this trash anymore, unload it.
Unload dtaEnvPigs

Me.MousePointer = vbNormal
dtaRepoSum.Refresh
End Sub

genie_ps
Newbie Poster
8 posts since Aug 2007
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
Question Answered as of 5 Years Ago by QVeen72, plusplus and Rich0001

To All good friends who replied and helped me, thanks a lot.

Qveen72 - God bless the queen. I hope
you found your rightful king.

Rich0001 - May you become richer.


plusplus - May you have more plus'es in your bank account.

God bless you all.

genie_ps
Newbie Poster
8 posts since Aug 2007
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Just ran across your post looking for help on something similar.

Have you cleared the 'save old data with report' box on the report file itself?

Open the report, under File // Report Options
there will be a checkbox for "Save Data With Report". If it is checked, uncheck it and see if that fixes the issue.

Thansk
klheitz

klheitz
Newbie Poster
1 post since Mar 2008
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

hope this thread would help you...

http://www.daniweb.com/forums/thread112160.html

cometburn
Junior Poster
122 posts since Feb 2008
Reputation Points: 12
Solved Threads: 19
Skill Endorsements: 0
Dim obj As New DataEnvironment1    'create object of DataEnvironment1
Set obj = New DataEnvironment1     'set
obj.Command1                       'execute command
Set DataReport1.DataSource = obj    'set datareport's datasource
DataReport1.Show

It retrive the updated database
reply me on [email removed]
:icon_razz: NjoY

ashishdahale86
Newbie Poster
2 posts since Mar 2011
Reputation Points: 8
Solved Threads: 0
Skill Endorsements: 0

Dim obj As New DataEnvironment1 'create object of DataEnvironment1
Set obj = New DataEnvironment1 'set
obj.Command1 'execute command
Set DataReport1.DataSource = obj 'set datareport's datasource
DataReport1.Show

THIS CODE RETRIEVE UPDATED DATABASE
Enjoy!!!!!!!!! :icon_smile:

ashishdahale86
Newbie Poster
2 posts since Mar 2011
Reputation Points: 8
Solved Threads: 0
Skill Endorsements: 0

Hello everyone. I need help for refreshing report please... I already tried all suggestions but didn't work..please reply.. thanx.

marsmodesto
Newbie Poster
1 post since Oct 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

hmmm....try u i.unload ang datareport... pero not your main form... solve na problem u po.... visit my website nlng for compliments... www.hamsori.weebly.com :)

hamsoriandungan
Newbie Poster
1 post since Jan 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.3502 seconds using 2.78MB