Dlookup random entry in table field

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

strSay = DLookup("[Saying]", "tblSay", "[Saying_ID] = intRandom")

this is the syntax I'm using to lookup an entry from the field [Saying] in
the table "tblSay", with a random saying id from the field [Saying_ID]

When I try it like this it gives me the error 2001: You canceled the
previous operation

When I replace the intRandom variable (Which is a randomly generated number)
with just a number it works. So why isn't it working with a variable?
 
Concatenate the value of the variable into the criterion expression:

strSay = DLookup("[Saying]", "tblSay", "[Saying_ID] =" & intRandom)
 
Back
Top