简体   繁体   English

获取空白数据报告vb6

[英]Getting a blank data report vb6

I am new to vb6. 我是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. 在“发票”和“ ItemsInvoice”表中输入数据。 Then getting the maxId using (Adodc) from the data base to show the last generated Invoice. 然后使用(Adodc)从数据库中获取maxId,以显示最后生成的发票。

Then passing the max Id as parameter to the data report which is showing the invoice according to the invoice id. 然后将最大Id作为参数传递给数据报告,该数据报告根据发票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. 对于数据报告,我使用的是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. 我猜数据报告为空的原因是因为没有该ID的记录,但实际上该记录正在数据库中插入。

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. 如果您的报表是手动移动通过记录集并仅基于传递的ID参数显示信息,然后对第二个报表使用相同的记录集,则可能只需要在记录集上移动MoveFirst即可将其放回开头。

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. 我不知道答案是否还会困扰您,但是如果其他人也有同样的问题,这里是该问题如何起作用的一个示例:想象一下,当第一人称时,有门和警卫正在监视谁进入( (第一个发票)到来,警卫为他注册,打开门(这是事件“ Load DataEnvironmet”),然后让小伙子通过。 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 守卫认为不会有人来打开门(指令认为DataEnvironment结束并且EOF值变为True),但是当第二个人来时(第二张发票),守卫不能问他是谁。 (再次具有该值,并在不注册他的情况下让其通过(这是第二张发票以及随后的发票为空白的原因)。解决方案是在一个人之后关闭门(“卸载DataEnvironment”)通过(显示数据报告后)。解决方案是上面Sangita提供的代码,但是在结束子级之前,您需要卸载正在使用的DataEnvironment。对我来说,它可以工作。对不起,如果答案不是您想要的,一直在寻找(如果其他人听不懂我在写什么,我的英语也不是很好)。以防万一我将用解决方案编写代码

 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 . 尝试使用data1.recordset.requeryData1.refresh类的刷新方法。 This should work if you use data controls. 如果使用数据控件,这应该可以工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM