Criteria Data Type Mismatch

  • Thread starter Thread starter Kevin
  • Start date Start date
K

Kevin

Hello Everyone,

To anyone who can help me with this pronblem, I say
thankyou in advance!

I have a form with a number of controls. Using the
afterupdate event on one of the controls I need to check a
table for records based on two fields in the table. One of
the fields is a text field and the other is a number of
type long.

The query is something like:

Select tableName.* from tableName where
(tableName.textfield='" & textfield criteria & "') and
(tableName.longfield='" & longfield criteria & "')

This query is fired from VBA as a dbopensnapshot type
recordset.

e.g. set rst=db.openrecordset(sqlstring,dbopensnapshot)

The query runs fine without the long field criteria, but I
get a runtime error 3464, data type mismatch if I include
the type long field.

The long field criteria is based on a number field in my
form.

HELP!

Do I have to convert the criteria?

Any help would be appreciated!!!

Kevin
..
 
Kevin

Your SQL has a slight error. It should read as follows:

Select tableName.* from tableName where
(tableName.textfield='" & textfield criteria & "') and
(tableName.longfield=" & longfield criteria)

Note that I have removed the single quotes surrounding
the criterion value for the long type field. These
single quotes are only necessary when dealing with text
or string type criteria. Numerics don't need them.

Hope that helps.
Keith
 
Thanks to both of you! I figured it was something like
that, but I was not sure of the syntax!

Thanks again!
 
Back
Top