Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

data report designer refrshing report 1

Status
Not open for further replies.

johnnyv

Programmer
Jul 13, 2001
216
CA
I am new to the DRD so bear with me

I have created a table in an access DB.The table holds data to be displayed by the DRD.The table is filled with data depending on options selected by the user. The user makes the proper selections then clicks a button to populate the table. This works every time.
The user then clicks a second button to view the report based on the info in the table.

My problem. The report is not always generated. In other words sometimes I get the report containing all of the info from the table and other times I get a blank page. Again please note that the table in question always contains the proper data before the report is generated.

My question

I believe that my problem lies somewhere in not 'refreshing' the connection between the data report and the dataenviroment which is linked/connected to the table in question.

So How can I be sure that the Data report always goes to the dataenviroemnt to get the required information before displaying the report

and
How do I make sure that the dataenviroment is always being 'refreshed' with the table in question.

Again I am new to this and I hope I am making some sense here


Thanks in advance for any responses.
 
Johnnyv

I believe your answer is to write a simple
If DataEnvironment1.yourCommandNameHere adStatusOpen Then
DataEnvironment1.yourCommandNameHere.close
End If

Command name(s) associated with your report(s) of course.

Your next call to this environment should rebind the report and requery your tables. This code goes in the
DataEnvironment1 Initialize code window. I had a simular problem as the MSDN libraries advised to place this code on a form in the on click command button section and it did not work.

Best of Luck!
bB
 
Sorry Johnnyv.......forgot
If DataEnvironment1.yourCommandNameHere.State adStatusOpen Then

left out the State.

bB
 
BoatBuny

Thanks for the reply

I have tried your code and still am running into problems.
So that I have it start in my head
the steps are as follows.
-I populate the information for the report into a table.
-I then show the report on the screen

for it to work correectly I need to close the connection to the DB each time before I preview the report so that a connection can be reestablished to allow for the new data to be in the report.
so in in laymans terms it shoud work like this correct?

1 populate the table in question with the proper data
2 check to see if the connection to the table is open
if so close it
3 call the data report this will reestablish a connection
to the table to get the correct data?


I have done all of the above and steped though the code as it executes

the connection is checked each time the report is called and closed if required before the report is shown( in the initialize procedure of the data enviroment


so what happens is most of the time the report generated is correct but the odd time the report is either blank or in correct. When this is the case I simply click the show report button a second time and the report then becomes accurate??

any suggestions??
 
Johnny:

Try this in the Private Sub DataReport_Initialize() section.

With DataEnvironment1
If .rsYourCommandObjectNameHere.State = adStateOpen Then
.rsYourCommandObjectNameHere.Close
End If
End With

I had just figured this out and was advising from home.

bB
 
BoatBunny thanks for the reply

I have added teh code mentioned in your last reply. For the most part it works but I am still running into the odd time where when previewing the report I get teh data from the previous report but when I click the preview button a second time the report is correct. the code above wiorks in that each tine I try to preview a new report the dataenvironemtn is initialized and the the 'command' is closed. there does not seem to be and steady pattern to this. I can preview 5-6 different reports and they look good but teh 6 or 7'th is off. As well VB is creating temp files in my project folder full do 'stuff' some of it is words some are symbols ??

thanks for your help to date any more suggestions would be great. Note that when I priew report only the following code is being executed

Private Sub cmdPreviewReport_Click()
TimeInfoReport.Show
End Sub

Public Sub DataEnvironment_Initialize()
With DataEnvironment1
If .rscmreport_Grouping.State = adStateOpen Then
.rscmreport_Grouping.Close
End If
End With
End Sub
 
Try putting the If statement in the DataReport_Initialize instead of the DE_Initialize.

Hope it works!

bB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top