Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / May 2008

Tip: Looking for answers? Try searching our database.

Problem with Criteria

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
George R - 18 May 2008 21:40 GMT
The following code produces the desired count of records when the
[PermitNumber] is <10000. It produces an error "type mismatch in criteria
expression" when [PermitNumber] is 10000 or greater. "most" is determined by
the length of the current Permit Number. Permit Number is a text field.

   myCriteria = "Left([PermitNumber]," & most & ") = " & myNum
   myCount = DCount("PermitNumber", "Property Master", myCriteria)

I would appreciate any assistance anyone could provide.
Thank you
Rick Brandt - 18 May 2008 22:20 GMT
> The following code produces the desired count of records when the
> [PermitNumber] is <10000. It produces an error "type mismatch in
[quoted text clipped - 7 lines]
> I would appreciate any assistance anyone could provide.
> Thank you

< 10000 and > 10000 is not meaningful on a Text field.  You need to use...

< "10000" and > "10000"

Of course this will be an alphabetical comparison, not numeric.

Signature

Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt   at   Hunter   dot   com

George R - 19 May 2008 02:41 GMT
I believe it is now a string. myNum is declared as a string and it appears as
"10000" (with the quotes) when the pointer rests over it. myCriteria appears
as "Left([PermitNumber],5) = 10000" with the quotes. The data type error
occurs.
With myNum as 9898, it similarly appears as "9898" and myCriteria appears as
"Left([PermritNumber],4) = 9898" (again, with the quotes) and there is no
error.

> > The following code produces the desired count of records when the
> > [PermitNumber] is <10000. It produces an error "type mismatch in
[quoted text clipped - 13 lines]
>
> Of course this will be an alphabetical comparison, not numeric.
Paolo - 19 May 2008 08:42 GMT
Hi George R,

try in this way
myCriteria = "Left([PermitNumber]," & most & ") = '" & myNum & "'"

HTH Paolo

> I believe it is now a string. myNum is declared as a string and it appears as
> "10000" (with the quotes) when the pointer rests over it. myCriteria appears
[quoted text clipped - 21 lines]
> >
> > Of course this will be an alphabetical comparison, not numeric.
Linq Adams - 19 May 2008 13:03 GMT
Using

Val(myNum)

will allow string/text data to be used as a number, assuming that the text
can be interpreted as a number.

Signature

There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.