[AccessD] Data Type Mismatch in criteria expression

McGillivray, Don DMcGillivray at ctc.ca.gov
Tue Dec 15 18:57:10 CST 2015


Right you are!

I've been so in the habit of doing it that way (based on the examples from MS) that I never tried it otherwise.  Figured it was required generally.

Hate to think of all the keystrokes I've wasted doing that . . .  :-P

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

Hi Don

Just a minor point in the context of the discussion, but... I think the brackets would only be necessary if there was a space in the name.

Regards
Steve

-----Original Message-----
From: McGillivray, Don
Sent: Wednesday, December 16, 2015 11:28 AM
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 

--
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