DAO FindFirst Criteria

D

Djoezz

I have difficulties in assigning a criteria for a search, I'm using DAO and I get this error message "Syntax error (missing operator) in expression".
My expression is : rst.FindFirst "[fldDate] = #" & Date & "# & " & "[fldInsertDesign] = '" & rstInsertDiscard.Fields("fldInsertDesign") & "'"

Basically, the criteria is to match 2 fields (fldDate and fldInsertDesign) in the table with the values from current date and a fields from another recordset.
Please help.

Cheers,
Djoezz
 
N

Nikos Yannacopoulos

Djoezz,

rst.FindFirst "[fldDate] = #" & Date & "# AND [fldInsertDesign] = '" &
rstInsertDiscard.Fields("fldInsertDesign") & "'"

should do it.

HTH,
Nikos

Djoezz said:
I have difficulties in assigning a criteria for a search, I'm using DAO
and I get this error message "Syntax error (missing operator) in
expression".
My expression is : rst.FindFirst "[fldDate] = #" & Date & "# & " &
"[fldInsertDesign] = '" & rstInsertDiscard.Fields("fldInsertDesign") & "'"
Basically, the criteria is to match 2 fields (fldDate and fldInsertDesign)
in the table with the values from current date and a fields from another
recordset.
 
T

Tim Ferguson

rst.FindFirst "[fldDate] = #" & Date & "# AND [fldInsertDesign] = '" &
rstInsertDiscard.Fields("fldInsertDesign") & "'"

should do it.

Not outside the USA it won't.


Tim F
 
D

Djoezz

Thanks Nikos
I'll give it a try,..

Tim
you mean the date format difference, right? I'll work on that ...thanks.
 
T

Tim Ferguson

Tim,
you mean the date format difference, right?

Yes. When sending stuff to SQL, it's advisable to bypass all the regional
setting stuff and format the things yourself:

strWhere = "fldDate = " & Format$(Date(), "\#yyyy\-mm\-dd\#")
strWhere = strWhere & " AND ...."

rst.FindFirst strWhere

B Wishes


Tim F
 
Top