Solved

How to Resolve the Type Mismatch Error in Sql Query using VBA Macros

Posted on 2010-08-25
3
428 Views
Last Modified: 2013-11-26
Hi, I am populating a Data from  MDB using VBA Macros. I am Facing a problem with the SQL Statement ERROR : Type Mismatch. But If i run the same code in Access Sql View , Its working properly .
How to solve This problem i attach my file for your clarification please guide me.
Thanks In Advance
test.zip
0
Comment
Question by:whspider
  • 2
3 Comments
 
LVL 2

Expert Comment

by:gordontm
ID: 33520359
Hi!
If you remove the two columns product.SKU and NORTH_2010.vles from the SELECT (as per the code attached), then the Type Mismatch problem goes away, so I recommend you use this is a starting point to solve the problem.


.CommandText = Array("select product.ProductID from product,Depot,Zones,NORTH_2010 where NORTH_2010.PrductID=product.ProductID and NORTH_2010.Mnth='January' and NORTH_2010.Type='PRE' and Zones.ID=NORTH_2010.ZoneID and Depot.DeptId=NORTH_2010.DepotID order by Depot.DepotName")

Open in new window

0
 

Author Comment

by:whspider
ID: 33520464
Thanks for your Comment, But Those two fields are mandatory fields,my doubt is why it shows error for that two fields . Is there is any other way to solve this error without removing the fields name
0
 
LVL 2

Accepted Solution

by:
gordontm earned 500 total points
ID: 33520501
OK. Try this instead

Replace this line

.CommandText = Array("select product...")

with

.CommandText = "select product..."

This worked for me when I tried it.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now