Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 20th, 2007, 08:15 AM
Registered User
 
Join Date: Jun 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Type Mismatch using Userform with Access Data

Hello
I have an excel Userform that is populating 2 listboxes from and access db (2003). I am using a SQL statement to pull the info into the listbox.

The first SQL Statement executes and populates as it should, but when it runs the second sql statement, it gives me a type mismatch.

Here is some of the code:

SQL statement 1 which works and populates properly:
sSQL = "SELECT Customers.CustID, Customer.Company " & _
    "FROM Customers ORDER BY Customers.CustID;"

SQL Statement 2 which gives the type mismatch:
stSQL2 = "SELECT Customer.Company,Quotes.QuoteID " & _
    "FROM Query1;"

Here is where the error is generated: In the first listbox, the only difference is the variable name and it is vaData instead of vaData2. The datatypes for ID fields are both autonumber, the FK datatype is number.

With .lbquotes
            .Clear
            .ColumnCount = 2
            .ColumnWidths = "0;1"
            .List = Application.Transpose(vaData2) 'This line generates the error
            .ListIndex = -1
End with

Any Ideas would be great.

TIA
Terry
 
Old June 21st, 2007, 03:37 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post
Default

Well a type mismatch is just that, the type on the right of the .List assignment is not the same type on the right..

The list property expects an array of variants. It was my understanding that Application.Transpose is now obselete, and that you can just use a Range object directly...

I would say break out the Appplication.Transpose code, and assign it to a variant array above this code block, see what that is returning and work with that.

Thats error trapping!

Best Regards,
Rob






Similar Threads
Thread Thread Starter Forum Replies Last Post
Data type mismatch sharon5469 ASP.NET 1.0 and 1.1 Basics 2 May 27th, 2007 10:01 AM
data type mismatch karma SQL Language 3 April 6th, 2006 07:58 AM
Getting Data Type mismatch for autonumber somissac General .NET 4 March 1st, 2006 12:02 AM
Data Type mismatch error clueless_may Access VBA 1 May 5th, 2004 09:16 AM
Data Type Mismatch error transcona Classic ASP Databases 4 June 25th, 2003 07:23 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.