[AccessD] Data Type Mismatch in criteria expression

Bob Heygood accesspro at gmail.com
Tue Dec 15 16:38:13 CST 2015


Thanks Don
And I thought that I had used all permutations of quotes !!

And also to Rocky in an off list message.

Thanks so much.



-----Original Message-----
From: AccessD [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of
McGillivray, Don
Sent: Tuesday, December 15, 2015 2:29 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Data Type Mismatch in criteria expression

Oops.  Meant to point out also that the column name "agentid" needs the
square brackets around it.

-----Original Message-----
From: McGillivray, Don 
Sent: Tuesday, December 15, 2015 2:27 PM
To: 'Access Developers discussion and problem solving'
Subject: RE: [AccessD] Data Type Mismatch in criteria expression

Try:

DCount("[agentid]", "agent", "[agentid] = '" & strAgentID & "'")

The criterion, being a string, must be surrounded by ' .



-----Original Message-----
From: AccessD [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Bob
Heygood
Sent: Tuesday, December 15, 2015 2:13 PM
To: 'Access Developers discussion and problem solving'
Subject: [AccessD] Data Type Mismatch in criteria expression

If you have a moment, can you look at this snippet ?


Don't judge me, I inherited the table and field names. And I figured it was
too much to change all the rookie naming conventions....

I just can't see the problem.

"agentid" is a field name in the table "agent". It is a primary key and a
STRING data type.
intAgentCount is a integer type vba variable.
strAgentID is a string type vba variable.

    intAgentCount = DCount("agentid", "agent", "[agentid] = " & strAgentID)

My objective is to determine if a record is already in the table for a given
agentid, and if not, to insert one.

TIA

Bob Heygood

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list