基于数组中的数字循环记录集定义 [英] Looping a recordset definition based on number from array

查看:71
本文介绍了基于数组中的数字循环记录集定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨伙计们,


我正在研究一个例程,它将从表格​​中选择一个包裹样本。每个地块属于人口普查区,并根据哪个区域进行某种计算。诀窍在于,数学只能在每个区域内随机的包裹样本上进行,并且样本的大小因每个区域而异。因此,我定义了一个带有变量的记录集,其中样本的大小是从另一个表填充的数组中的值,执行操作,然后循环返回以重新定义记录集。我得到一个超出范围错误的下标,所以闻起来有点像数组问题,但它是我的sql字符串突出显示,在第44行。我在声明部分有选项base 1。任何人都可以通过传递一个值来定义在续集查询中请求了多少记录的实际或概念问题吗?

Hi folks,

I am working on a routine that will select a sample of parcels from a table. Each parcel belongs to a census tract, and depending on which tract, a certain calculation is applied. The trick is that the math is only to be performed on a random sample of parcels within each tract, and the size of the sample varies for each tract. Therefore, I define a recordset with a variable where the size of the sample is a value in an array populated from another table, perform the action, and then loop back to redefine the recordset. I get a subscript out of range error, so that smells a bit like an array issue, but it is my sql string that is highlighted, down in line 44. I have option base 1 in the declarations section. Can anyone see the practical, or for that matter conceptual problem with passing a value to define how many records are requested in the sequel query?

展开 | 选择 | Wrap | 行号

推荐答案

您正在尝试在SQL语句的上下文中使用数组(singleunitsadd(dim1,dim2)),该语句是从FROM子句中未列出的表派生的。我甚至不认为这种方法是可行的,但即使是这样,也会因为singleunitsadd(k,1)而生成下标超出范围的错误。从我所看到的,k到目前为止尚未初始化,因此将包含0的值。问题是选项库1已经明确说明,因此singleunitsadd(0,1)处的数组元素没有意义。希望这可以帮助。顺便说一句,这似乎是填充多维数组的一种非常规的方式,它通常在嵌套的For ... Next结构中完成。
You are trying to use an Array (singleunitsadd(dim1, dim2)) within the context of an SQL Statement that is derived from a Table not listed in the FROM Clause. I don''t even think that this approach is possible, but even if it were, the Subscript out of range Error would be generated because of singleunitsadd(k, 1). From what I can see, k is not initialized up to this point and thus would contain the value of 0. The problem is that Option Base 1 has been explicitly stated so the Array Element at singleunitsadd(0, 1) makes no sense. Hope this helps. BTW, this seems to be a very unorthodox way to populate a Multidimensional Array, it is customarily done within nested For...Next constructs.



您正在尝试在SQL语句的上下文中使用数组(singleunitsadd(dim1,dim2)),该语句是从FROM子句中未列出的表派生的。我甚至不认为这种方法是可行的,但即使是这样,也会因为singleunitsadd(k,1)而生成下标超出范围的错误。从我所看到的,k到目前为止尚未初始化,因此将包含0的值。问题是选项库1已经明确说明,因此singleunitsadd(0,1)处的数组元素没有意义。希望这可以帮助。顺便说一句,这似乎是填充多维数组的一种非常非常规的方式,它通常在嵌套的For ... Next结构中完成。
You are trying to use an Array (singleunitsadd(dim1, dim2)) within the context of an SQL Statement that is derived from a Table not listed in the FROM Clause. I don''t even think that this approach is possible, but even if it were, the Subscript out of range Error would be generated because of singleunitsadd(k, 1). From what I can see, k is not initialized up to this point and thus would contain the value of 0. The problem is that Option Base 1 has been explicitly stated so the Array Element at singleunitsadd(0, 1) makes no sense. Hope this helps. BTW, this seems to be a very unorthodox way to populate a Multidimensional Array, it is customarily done within nested For...Next constructs.



我认为您想要引用的表在第16行中列出?无论如何,我删除了基本1声明并假设0作为开始,并且下标超出范围错误不再是。现在我得到错误号91:描述;对象变量或未设置块变量"。这不是一个运行时错误,而是一个没有调试选项的文本框。由于我没有宣布任何物品,我不知道问题是什么。有什么想法?

I think the table you want a reference to is listed in line 16? At any rate, I eliminated the base 1 declaration and assumed 0 as the start, and the Subscript out of range Error is no more. Now I get "Error No. 91: Description; Object variable or With block variable not set". This does not come up as a runtime error, but rather as a text box without the debug option. Since I don''t declare any objects, I don''t see what the problem is. Any ideas?



我认为您想要引用的表在第16行中列出?无论如何,我删除了基本1声明并假设0作为开始,并且下标超出范围错误不再是。现在我得到错误号91:描述;对象变量或未设置块变量"。这不是一个运行时错误,而是一个没有调试选项的文本框。由于我没有宣布任何物品,我不知道问题是什么。有任何想法吗?
I think the table you want a reference to is listed in line 16? At any rate, I eliminated the base 1 declaration and assumed 0 as the start, and the Subscript out of range Error is no more. Now I get "Error No. 91: Description; Object variable or With block variable not set". This does not come up as a runtime error, but rather as a text box without the debug option. Since I don''t declare any objects, I don''t see what the problem is. Any ideas?



我想我发现了问题..我正在循环记录集的定义,每次为新类创建一个新的记录集(基于变量)在表中)并对该类进行计算。但是,我关闭并将记录集对象设置为空,所以当下次循环运行时,我得到错误号91:描述;对象变量或未设置块变量"。现在在循环结束时我没有将记录集对象设置为空,但是我关闭它。(我为每个类循环而不是使用过滤器方法重新填充记录集的原因是我要选择每个类只有一个随机子集;因此我将一个变量传递给sql语句,确定要返回多少个顶级记录。我不认为我可以用过滤方法指定行数)

I think I found out the problem.. I was looping the definition of a recordset, each time creating a new recordset for a new class (as based on a variable in the table) and performing calculations on that class. However, I closed and set the recordset object to nothing, so when the loop ran the next time, I got"Error No. 91: Description; Object variable or With block variable not set". Now at the end of the loop I don''t set the recordset object to nothing, BUT I do close it.(the reason I re-populate the recordset each each class loop rather than using a filter method is that I want to select only a random subset of each class; hence I pass a variable to the sql statement determing exactly how many top records to return. I don''t think I can specify the number of rows with the filter method)


这篇关于基于数组中的数字循环记录集定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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