Discussion Locked

Refreshing Visual Basic Data Environment

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have created a report in Visual Basic designed with DataReport. It only has one table associated with it and is a fairly simple report.

My problem is when I view the report, or print it, none of the changes that I have made to the database while using the application show up in the report. If I close the app and restart it, the changes will show up on the report. It seems that once the DataEnvironment is loaded and the values pulled in from the table it is done and any changes to the underlying table aren't reflected in the DataEnvironment until the app is restarted.

Is there a way to "refresh" the DataEnvironment to get the changes made during the current session of the application?

5 replies

by bill_h

The Data Environment designer has a refresh button which, according to the documentation:

"Refreshes a Command object, rebuilding all its stored meta-data, such as Field and Parameter objects. Any changes to the table or stored procedure's definition is reflected in the Command object after the refresh.

Caution User-defined property settings are lost during the refresh. For Fields, the Control and Caption properties are reset to their defaults. For Parameters, the Name, Direction, DataType, Precision, Scale, Size, and HostDataType properties are reset."

Press F1 while the Data Environment designer is open to view the docs.

by ggardner

I appreciate the response, but I knew about that already--it works fine in the design mode. What I need is some way to refresh during runtime. I should have made that more clear.

by bill_h

Well, if I had read your question correctly the *first* time, I would have realized you were asking for a run-time solution...mea culpa.

This can be accomplished during *run-time* by re-binding the DataReport to the DataEnvironment, i.e.,

Dim deDataEnv As DataEnvironment1
Dim drReport As DataReport1

Set deDataEnv = New DataEnvironment1
Set drReport = New DataReport1
'Next line does the trick
Set drReport.DataSource = deDataEnv
drReport.Show 'or drReport.PrintReport
Set drReport = Nothing

Resetting the DataSource property forces a requery of the command specified in the DataMember property. You do not need to specify the value of the DataMember property.

Hope this helps...

This discussion is closed to new replies.