Is there an "EVALUATE" command in Access for strings?

G

Guest

I need to know if there is an evaluate command for strings in Access?

For example, if I create a variable lsSQL that contains the value:

lsSQL = "[Field1] = ' " & rsRecordset(""Field1"") & " ' "

and then I open a recordset and want to use the lsSQL as a parameter for the
FindFirst command, like this:

rsAnotherRecordset.FindFirst lsSQL

I need to evaluate lsSQL first, because if rsRecordset(""Field1"") contains
"My Value", then I want the FindFirst to do this:

rsAnotherRecordset.FindFirst "[Field1] = 'My Value' "

and not do this:

rsAnotherRecordset.FindFirst "[Field1] = ' " & rsRecordset(""Field1"") & " ' "

So, I need a command that will do something like this:

rsAnotherRecordset.FindFirst Evaluate(lsSQL)

Dave
 
R

Ron Weiner

Dave

I am sure all of this makes sense to you, but I am not following what you
are trying to do. However you will find an Eval() function in Access which
might be what you think you need. It is still a little early in the AM on
the East coast of the US, perhaps I should get another cup of Coffee and
then re-read your post.

Ron W
 
G

Guest

Either of these is the correct way to do this:
IsSQL = "[Field1] = ' " & rsRecordset.Fields("Field1") & " ' "
rsAnotherRecordset.FindFirst lsSQL
Or:
rsAnotherRecordset.FindFirst "[Field1] = ' " & rsRecordset.Fields("Field1")
& " ' "
 

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


Top