问题描述
我正在这里进行一些VBA编程,并且我有一个 Private Const
,其中包含两个元素,如下所示:
I am doing some VBA programming here, and I have a Private Const
with two elements as follows:
Private Const myList as String = "foo;bar"
然后我有一个像这样的循环结构:
I then have a looping structure like this:
myTerms = Split(myList,";")
For I = 0 to UBound(myTerms)
'do stuff in here
Next I
最后,这是新部分.在tblWords中有100个不同的行,仅由一个ID字段和一个文本字段组成,例如 tblWords.ID
和 tblWords.Word
.
Finally, here is the new part. In tblWords there are 100 different row, consisting of simply an ID field, and a text field such as tblWords.ID
and tblWords.Word
.
我的问题是:与使用 Private Const
而不是循环两次相比,我如何修改我的循环,以使其一次循环遍历 tblWords
100次每行?
My question is: Instead of using the Private Const
and looping twice, how can I modify my loop so that it will instead loop over the tblWords
100 times, once for each row?
推荐答案
我想你的意思是
Dim rs As DAO.Recordset
Dim db As Database
Set db = CurrentDB
Set rs = db.OpenRecordset("tblWords")
Do While Not rs.EOF
sid = rs!ID
sword = rs!word
''And to change a word
rs.Edit
rs!Word = rs!Word & " edited"
rs.Update
rs.MoveNext
Loop
这篇关于在Access中循环表行(使用或不使用Private Const)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!