循环和分配不起作用 [英] Loops and Assignments not working

查看:68
本文介绍了循环和分配不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿所有,我又来了!


我已经创建了这个子程序,也许我只是不太了解循环,但这就是我想出的东西,它不用工作。


总结一下,我运行一个sql语句,检索一些值并将它们放入一个数组中。


ie

记录(0)= A

记录(1)= C

记录(2)= D


那么我需要做的是,通过循环遍历该数组,将数据从基于每个记录集的表中拉出来,将值分配给名为rptTitle1,rptTitle2,rptTitle3,rptPage1,rptPage2,rptPage3的报表上的未绑定文本框,以及例如,rptTitle1 =" Holdings",rptPage1 = 1,rptTitle2 =" NetInvestment",rptPage2 = 4 ..我想,我希望,你可以看到我要去哪里。但我的代码,循环多次,文本框没有分配他们的值。我的子程序如下:

Hey all, Me again!

I have created this subroutine, and maybe I just don''t understand loops well enough, but this is what I came up with and it is not working.

To summarize, I run an sql statement that retrieves some values and places them into an array.

i.e.
Record(0) = A
Record(1) = C
Record(2) = D

Then what I need to do, is assign values to my unbound text boxes on the report named rptTitle1, rptTitle2, rptTitle3, rptPage1, rptPage2, rptPage3 by looping through that array, pulling data out of a table based on each recordset, and assign for example rptTitle1 = "Holdings", rptPage1 = 1, rptTitle2 = "NetInvestment", rptPage2 = 4.. I think, i hope, you can see where I am going with this. But my code, loops to many times, and the text boxes are not being assigned their values. My sub routine follows:

展开 | 选择 | Wrap | 行号

推荐答案


嘿所有,我又来了!


我已经创建了这个子程序,也许我只是不太了解循环,但这就是我提出来的这是行不通的。


总结一下,我运行一个sql语句,检索一些值并将它们放入一个数组中。


ie

记录(0)= A

记录(1)= C

记录(2)= D


然后我需要做的是,通过循环遍历该数组,将数据分配给名为rptTitle1,rptTitle2,rptTitle3,rptPage1,rptPage2,rptPage3的报告上的未绑定文本框。一个基于每个记录集的表,并分配例如rptTitle1 =" Holdings",rptPage1 = 1,rptTitle2 =" NetInvestment",rptPage2 = 4 ..我想,我希望,你可以看到我的目标。但我的代码,循环多次,文本框没有分配他们的值。我的子程序如下:

Hey all, Me again!

I have created this subroutine, and maybe I just don''t understand loops well enough, but this is what I came up with and it is not working.

To summarize, I run an sql statement that retrieves some values and places them into an array.

i.e.
Record(0) = A
Record(1) = C
Record(2) = D

Then what I need to do, is assign values to my unbound text boxes on the report named rptTitle1, rptTitle2, rptTitle3, rptPage1, rptPage2, rptPage3 by looping through that array, pulling data out of a table based on each recordset, and assign for example rptTitle1 = "Holdings", rptPage1 = 1, rptTitle2 = "NetInvestment", rptPage2 = 4.. I think, i hope, you can see where I am going with this. But my code, loops to many times, and the text boxes are not being assigned their values. My sub routine follows:

展开 | 选择 | Wrap | 行号


是的,这似乎无法奏效。


页面上有12个未绑定的文本框。其中6个是可能的报告标题(从getrows中提取)。其他6个用于由变量pg分配的页码。我确实意识到我不需要两个for循环,因为这是导致循环次数太多的问题。现在我已经弄明白了,我只需要适当地填充文本框。此外,当我到达rptTitle = T.getrows(T.recordcount)时,我得到一个类型不匹配。毫无疑问,我试图做错了。
Yeah, that doesn''t seem to work.

There are 12 unbound text boxes on the page. 6 of them for possible report titles (pulled from getrows ). The other 6 are for page numbers assigned by variable pg. I did realize that I had no need for two for loops as this is what was causing my issues with looping too many times. Now that I have that figured out, all I need is to populate the text boxes appropriately. Also, when I get down to rptTitle = T.getrows(T.recordcount), i get a type mismatch. No doubt I am trying to do it wrong.



是的,这似乎无法奏效。


页面上有12个未绑定的文本框。其中6个是可能的报告标题(从getrows中提取)。其他6个用于由变量pg分配的页码。我确实意识到我不需要两个for循环,因为这是导致循环次数太多的问题。现在我已经弄明白了,我只需要适当地填充文本框。此外,当我到达rptTitle = T.getrows(T.recordcount)时,我得到一个类型不匹配。毫无疑问,我试图做错了。
Yeah, that doesn''t seem to work.

There are 12 unbound text boxes on the page. 6 of them for possible report titles (pulled from getrows ). The other 6 are for page numbers assigned by variable pg. I did realize that I had no need for two for loops as this is what was causing my issues with looping too many times. Now that I have that figured out, all I need is to populate the text boxes appropriately. Also, when I get down to rptTitle = T.getrows(T.recordcount), i get a type mismatch. No doubt I am trying to do it wrong.


另外,当我到达rptTitle = T.getrows(T.recordcount)时,我得到一个类型不匹配。毫无疑问,我试图做错了。
Also, when I get down to rptTitle = T.getrows(T.recordcount), i get a type mismatch. No doubt I am trying to do it wrong.

  1. 您正在尝试将GetRows()方法的返回值分配给字符串变量(如第13行中声明的那样 - rptTitle)。 GetRows()的返回只能是一个声明为Variant的变量,以便它可以保存二维数组。
  2. 我不认为你的SQL语句(sql1)会正确过滤掉任何临时数据报告对象(〜临时报告),并且不需要GROUP BY子句,请尝试:
  1. You are trying to assign the return of the GetRows() Method to a String Variable (as Declared in Line #13 - rptTitle). The return from GetRows() can only be a Variable declared as Variant, in order that it may hold the 2-Dimensional Array.
  2. I do not think your SQL Statement (sql1) will properly Filter out any Temporary Report Objects (~Temp Report), and there is no need for a GROUP BY Clause, try:
展开 | 选择 | Wrap | 行号


这篇关于循环和分配不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆