Criteria string

  • Thread starter Thread starter Jane
  • Start date Start date
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
 
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.
 
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


.
 
Back
Top