2

我在这里做一些 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我如何修改我的循环而不是使用 and 循环两次,以便它循环tblWords100 次,每行一次?

4

1 回答 1

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
于 2013-01-13T20:46:40.860 回答