Wrox Programmer Forums
Pro Visual Basic 2005 For advanced Visual Basic coders working in version 2005. Beginning-level questions will be redirected to other forums, including Beginning VB 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro Visual Basic 2005 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 April 10th, 2006, 07:56 AM
Authorized User
Join Date: Oct 2003
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default type mismatch

I am experiencing a coding problem.
Essentially at this point all i'm trying to do is populate a combo box with data coming from a client table. The code appears sound however I receive a "TYPE MISMATCH" error during compilation.
The debugger points to the 'additem' property.Please review my code and tell me if you can spot the problem. Thanks in advance.
Private Sub Form_Load()

'Declare Variables
Dim cnn As ADODB.Connection
Dim AccessConnect As String
Dim ASql As String
Dim rsClient As New Recordset

Set cnn = New ADODB.Connection
AccessConnect = "DSN=Sigmund;" & _
                     "Database=sigmundt.mdb;" & _
                     "DefaultDir=D:\documents and settings\administrator.gizmo\my documents" & _
                     "visual studio projects\gizmo\client.mdb;" & _

cnn.ConnectionString = AccessConnect
'Build the SQL statement

'Open a recordset
rsClient.Open ASql, cnn, adOpenStatic, adLockReadOnly
Set Combo1.DataSource = rsClient
Do While Not rsClient.EOF

    Combo1.AddItem rsClient
Combo1.DataField = "FirstName"

Old April 11th, 2006, 08:35 AM
Registered User
Join Date: Apr 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts

I may be wrong, but I don't think you need to set the datasource property of the Combo1 combo box. I'd recommend either binding the combo box to a datasource through the Visual Basic.net IDE (which allows you to set your select statement, display text, and item value), or, do NOT bind the combo box to a data source, and do not bind the data field. You'll have to add some extra code to grab the selectedItem from the combo box and use that in your database.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Type Mismatch Anup Gavate VB How-To 4 March 28th, 2005 01:48 PM
Type mismatch NoBullMan Classic ASP Basics 2 November 16th, 2004 03:16 AM
Type mismatch per.holleufer Classic ASP Basics 5 July 31st, 2004 07:33 AM
Type mismatch sporkman43 Classic ASP Basics 4 August 14th, 2003 03:27 AM

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