-1

I am trying to take many values (which always change) from a table in access and put them inside a limit of a SQL statement.

I have Dlookup() but as we know it is pulling only 1 value.

How can I loop this to pull all the value?

related code:

  1. Dim Value as string
  2. Value = DLookup("Values", "value")
  3. sSQL = ......... WHERE AL.LIMIT '" & value & "'" &_
Kazimierz Jawor
  • 18,861
  • 7
  • 35
  • 55

1 Answers1

0

I have no idea what you're trying to do, your question is about as clear as mud. However, I'm gonna take a stab at it.

Try something like this:

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 & "'"

That is gonna need a lot of editing, but if I understood correctly, it should be a good starting point.

Johnny Bones
  • 8,786
  • 7
  • 52
  • 117