我在这里做一些VBA编程,我有一个Private Const
,其中有两个元素如下:
Private Const myList as String = "foo;bar"
然后我有一个像这样的循环结构:
myTerms = Split(myList,";")
For I = 0 to UBound(myTerms)
'do stuff in here
Next I
最后,这是新的部分。在tblWords中有100个不同的行,仅包含ID字段和文本字段,例如tblWords.ID
和tblWords.Word
。
我的问题是:我没有使用Private Const
并循环两次,而是如何修改我的循环以使其反复循环tblWords
100次,每行一次?
答案 0 :(得分:3)
我认为你的意思是
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