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.