Criteria string

J

Jane

I am having problems with findfirst and dcount using the
following criteria strings:

rstCalen.FindFirst "[sessionid] = """ & SessID & """ and
[areaid]" = DareaID

if narrow down the criteria and do not include the second
part, the findfirst request is successful. (although the
second criteria is also true).

Sessionid is a string and SessId is declared as a string.
AreaID is a number and DareaID is declared as a variant.
The recordset is based on a query on the original table.

Any help with the criteria would be much appreciated.

Jane
 
A

Allen Browne

The 2nd equal sign needs to be inside the string:
rstCalen.FindFirst "[sessionid] = """ & SessID & """ AND [areaid] = " &
DareaID

You might wonder how Access could interpret it as it was.
It makes a string containing something like:
[sessionid] = "xx" and [areaid]
Then it compares that DareaID, and says the 2 are not equal, so the
expression is False.
When it executes
rstCalen.FindFirst False
nothing can possibly match, because the condition is already false.
 
J

Jane

Makes perfect sense when explained. I have been looking at
the string until my eyes ached. Thanks for your help.
Jane
-----Original Message-----
The 2nd equal sign needs to be inside the string:
rstCalen.FindFirst "[sessionid] = """ & SessID & """ AND [areaid] = " &
DareaID

You might wonder how Access could interpret it as it was.
It makes a string containing something like:
[sessionid] = "xx" and [areaid]
Then it compares that DareaID, and says the 2 are not equal, so the
expression is False.
When it executes
rstCalen.FindFirst False
nothing can possibly match, because the condition is already false.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

I am having problems with findfirst and dcount using the
following criteria strings:

rstCalen.FindFirst "[sessionid] = """ & SessID & """ and
[areaid]" = DareaID

if narrow down the criteria and do not include the second
part, the findfirst request is successful. (although the
second criteria is also true).

Sessionid is a string and SessId is declared as a string.
AreaID is a number and DareaID is declared as a variant.
The recordset is based on a query on the original table.

Any help with the criteria would be much appreciated.

Jane


.
 

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

Top