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 / February 2008

Tip: Looking for answers? Try searching our database.

DataType Mismatch error

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
GACarGuy - 27 Feb 2008 01:39 GMT
I'm missing something really simple but I don't see.  When I run the code
below I am getting a data mismatch error on the last execute statements.

Function WorkListBuild()
'Route Variables
   Dim b As Integer
   b = 15

'This line Works
   Set rs = cn.Execute("SELECT COUNT(lacct) From tblWorkLists WHERE
DaysPastDue = 15 ")

'This line does not,
   Set rs = cn.Execute("SELECT COUNT(lacct) From tblWorkLists WHERE
DaysPastDue =  b ")

End Function

Thanks for the help
Daniel Pineault - 27 Feb 2008 01:42 GMT
Try

   Set rs = cn.Execute("SELECT COUNT(lacct) From tblWorkLists WHERE
DaysPastDue =  " & b )
Signature

Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com
If this post was helpful, please rate it by using the vote buttons.

> I'm missing something really simple but I don't see.  When I run the code
> below I am getting a data mismatch error on the last execute statements.
[quoted text clipped - 15 lines]
>
> Thanks for the help
John W. Vinson - 27 Feb 2008 01:58 GMT
>I'm missing something really simple but I don't see.  When I run the code
>below I am getting a data mismatch error on the last execute statements.
[quoted text clipped - 13 lines]
>
>End Function

You need to concatenate the *value* of the variable into the query, not its
name. The JET query engine doesn't know anything about VBA variables. Try

   Set rs = cn.Execute("SELECT COUNT(lacct) From tblWorkLists WHERE
DaysPastDue =  " & b )
Signature

            John W. Vinson [MVP]

 
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.