开发者

Getting a blank data report vb6

开发者 https://www.devze.com 2022-12-21 18:33 出处:网络
I am new to vb6. I am working to create the invoice generation application. I am using data report to show the generated invoice.

I am new to vb6. I am working to create the invoice generation application. I am using data report to show the generated invoice. The step by step working of process is:

Entering the data in to Invoice and ItemsInvoice tables. Then getting the maxId using (Adodc) from the data base to show the last generated Invoice.

Then passing the max Id as parameter to the data report which is showing the invoice according to the invoice id.

It is working fine when I first开发者_如何学运维 time generate invoice. Now for 2nd invoice without closing application I am getting a blank data report. For data report I am using dataenvironment.

I am guessing the reason the data report is blank is because there was no record for that Id, but actually the record is inserting in the database.

What is going wrong?


I'm not sure how your data set is getting configured, but it sounds like you have a single record in the data and aren't reloading it properly. If your report is manually moving through the recordset and only showing info based on the ID parameter you are passing it and then using the same recordset for the second report, you probably just need to MoveFirst on the recordset to put it back at the beginning.


Load the data environment and refresh the data report. I am also generating report in the similar fashion. I faced this problem. Here's the solution

Load DataEnvironment1
With DataEnvironment1
     'Command1 is the command added to data environment where you fire query or 
     'set it to point to a table

    If .rsCommand1.State <> 0 Then .rsCommand1.Close
    .Command1 maxid         'parameter you pass to the recordset

End With
DataReport1.Refresh
DataReport1.Show

Thats it! You are done. I m sure it will work. Do tell me if it doesn't.


I don't know if the answer will still bother you, but if someone else have the same problem here is a example of how the problem works: Imagine that there is a gate and a guard looking who is entering, when the first person (the first invoice) comes, the guard registers him, opens the gate (This is the event "Load DataEnvironmet") and then lets the guy pass. The guard believes that no one else would come and lets the door open (the instruction believes that the DataEnvironment ends and the value EOF becomes True), but when the second guy comes (the second invoice) the guard can't ask him who is (has, again, the value and lets it pass without registering him (this is the reason why the second invoice, and subsequent in while invoice would come blank). The solution is to close the gate ("Unload DataEnvironment") after a guy passes (After showing the data report). The solution is the code given from Sangita above, but just before ending the sub you need to unload the DataEnvironment you were working on. For me, it works. Sorry if the answer is not what you were looking for (and also if someone else can't understand what I'm writing, my English isn't very good). Just in case I will write the code with the solution

 Load DataEnvironment1
 With DataEnvironment1

   If .rsCommand1.State <> 0 Then
     .rsCommand1.Close
   End If
   .Command1 Value(ID)  

 End With
 DataReport1.Refresh
 DataReport1.Show
 Unload DataEnvironment1


Try a refresh method like data1.recordset.requery or Data1.refresh. This should work if you use data controls.

0

精彩评论

暂无评论...
验证码 换一张
取 消