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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top