-1

我试图从访问中的表中获取许多值(总是更改)并将它们放在 SQL 语句的限制内。

我有 Dlookup() 但我们知道它只提取 1 个值。

我怎样才能循环这个来提取所有的价值?

相关代码:

  1. Dim Value as string
  2. Value = DLookup("Values", "value")
  3. sSQL = ......... WHERE AL.LIMIT '" & value & "'" &_
4

1 回答 1

0

我不知道你想做什么,你的问题就像泥巴一样清晰。不过,我要试一试。

尝试这样的事情:

Dim db as Database
Dim rec as Recordset

Db = CurrentDB
'This assumes you're pulling one specific record from a table with many records
rec = db.OpenRecordSet("Select * from YourTableName WHERE Something = SomethingElse")

Do While rec.EOF = False
  MyFirstValue = rec(0)
  MySecondValue = rec(1)
  MyThirdValue = rec(2)
  ...ect
Loop

sSQL = "Select * from Whatever WHERE FirstParam = '" & MyFirstValue & "' AND SecondParam = '" & MySecondValue & "' AND ThirdParam = '" & MyThirdValue & "'"

这将需要大量编辑,但如果我理解正确,这应该是一个很好的起点。

于 2013-08-06T20:20:22.630 回答