
How to refresh data on a VB 6.0 Data Report
I have a report designed with VB 6.0 Data Report. This report takes its
input from a Command in the Data Environmet that executes a Select query in
an Access 97 database. I run the report from a form in an MDI environment. I
have another form that changes the table in the Access database that feeds
the report. What happens is that whenever I add or delete a record in the
table using the latter form, the report needs to be run twice to see the
changes. In other words, 1) you run the report and see record X, 2) you
delete record X and run the report again, 3) the record is still on the
report, 4) you run the report again and now the record is gone. The same
thing happens for additions to the table. What could be happening? A piece
of the code follows.
'In what follows:
'dePayrollP is de DataEnvironment
'cmdEmployeesP is the command that feeds the report
'rscmdEmployeesP is the recordset underlying the command
'rptEmployeesP is the report.
'To see the changes, you have to go twice through the following code.
If dePayrollP.rscmdEmployees.State = adStateClosed Then
dePayrollP.rscmdEmployees.Open
End If
dePayrollP.rscmdEmployees.Requery
Set rptEmployeesP.DataSource = dePayrollP 'I think I'm rebinding here
dePayrollP.rscmdEmployees.Close 'This statement makes no difference
rptEmployeesP.Show
---Alberto.