Solved

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

Posted on 2010-08-25
3
426 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

747 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

9 Experts available now in Live!

Get 1:1 Help Now