使用带RecordSet的变量

时间:2017-10-31 17:49:59

标签: vba ms-access access-vba dao ms-access-2013

我试图通过使用记录集来迭代表。这是我的语法,但我的问题是,如果我为rsInsert!StoreNumber执行Debug.Print,它总是空白的!现在如果我为storenumfield执行Debug.Print它包含一个值。在Insert语句中使用变量的正确方法是什么?如下所示?

Dim rsSelect As DAO.Recordset, rsInsert As DAO.Recordset, db As DAO.Database
Set db = CurrentDb
Set rsSelect = db.OpenRecordset("Select DISTINCT [_SpreadsheetImport]." & storenumfield & " FROM [_SpreadsheetImport]")
Set rsInsert = db.OpenRecordset("NewTable")
Do While Not rsSelect.EOF
    rsInsert.AddNew
    rsInsert!StoreNumber = rsSelect!& storenumfield
    rsInsert![VID] = ConcatRelated("[VID]", "[_SpreadsheetImport]", "[snF] =" & rsSelect!snF)
    rsInsert.Update
    rsSelect.MoveNext
Loop

@Erik von Asmuth撰写的原始语法 - >链接到个人资料

https://stackoverflow.com/users/7296893/erik-von-asmuth

- >这里有完整的帖子

Character Limit On ConcatRelated() Function

0 个答案:

没有答案