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

You are currently viewing the Access 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 December 28th, 2005, 02:37 AM
Registered User
 
Join Date: Dec 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Runtime Error 13: Type Mismatch in VB6

hi! i have some problem with this certain code. when i try to run the form and click the process button. it gives me runtime error 13: type mismatch in w/c it is pointing to the code ["Set lstViewList = lstView.ListItems.Add(, , Trim$(tble(0)))"], though the data on the said database are basically characters only. may it strings/ integer it still gives me this error. i hope you guys could help me with this. thanks in advance!

Option Explicit

Dim conn As New rdoConnection
Dim tble As rdoResultset
Dim strconn As String
Dim strtble As String
Dim lstViewList As ListItem

Private Sub cmd_Click()
Select Case cbo.ListIndex
    Case 0
        strconn = "SourceType=DBF;" _
            & "SourceDB=" & dbfPathMain & ";" _
            & "Driver={Microsoft Visual FoxPro Driver}"
    Case 1
        strconn = "SourceType=DBF;" _
            & "SourceDB=" & dbfPathNorth & ";" _
            & "Driver={Microsoft Visual FoxPro Driver}"
End Select

If cbo.ListIndex > 1 Then
    MsgBox "Please select which building you want to get the data!", vbCritical, "ERROR"
    Exit Sub
End If

conn.Connect = strconn

conn.CursorDriver = rdUseOdbc
conn.EstablishConnection "rdDriverNoPrompt"

strtble = "SELECT customer FROM receipt.dbf WHERE or_date = {^" & dtp.Value & "};"
Set tble = conn.OpenResultset(strtble, rdOpenKeyset, rdConcurRowVer)

lstView.ListItems.Clear
If tble.RowCount <> 0 Then tble.MoveFirst
Do While Not tble.EOF
    Set lstViewList = lstView.ListItems.Add(, , Trim$(tble(0)))
    tble.MoveNext
Loop
End Sub

 
Old December 28th, 2005, 07:54 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

Hello,

Your error isn't a data type error, its an object type error.

This looks like VB.NET code to me:

lstView.ListItems.Clear
If tble.RowCount <> 0 Then tble.MoveFirst
Do While Not tble.EOF
    Set lstViewList = lstView.ListItems.Add(, , Trim$(tble(0)))
    tble.MoveNext
Loop

In VB6 I would just do:

lstView.Clear
If tble.RecordCount <> 0 Then tble.MoveFirst
   Do While Not tble.EOF
      lstView.AddItem tble(0)
      tble.MoveNext
   Loop
End If

Or I like to add the records primary key value to the ItemData property:

lstView.Clear
If tble.RecordCount <> 0 Then tble.MoveFirst
   Do While Not tble.EOF
      lstView.AddItem tble!DataItem1
      lstView.ItemData(lstView.NewIndex) = tble!DataID
      tble.MoveNext
   Loop
End If

I'm also using ADO here, hence RecordCount.

HTH,

Bob










Similar Threads
Thread Thread Starter Forum Replies Last Post
getting runtime error 13: type mismatch rita9 Beginning VB 6 2 March 14th, 2008 04:36 AM
hi i got runtime error 13 Type Mismatch error sriharsha345 Access VBA 2 February 21st, 2008 09:30 AM
runtime error '13' type mismatch denkidude Visual Basic 2005 Basics 5 March 15th, 2007 10:28 PM
Why am I getting Runtime Error 13: Type Mismatch? dan_thorman Excel VBA 1 January 24th, 2007 02:06 PM
Error 13 Type Mismatch lguzman Access VBA 2 January 6th, 2005 10:19 PM





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