Select to view content in your preferred language

Type Mismatch error in VBA for ArcGIS 10

1623
5
08-06-2010 03:59 AM
BradChappell
Emerging Contributor
Just trying out some of our old VBA code ArcGIS 10 and getting a type mismatch error where I should NOT be getting one.

Here is the code:
Dim DS as IDataSet
Set DS = MyTable
Dim TableName As IName         
Set TableName = DS .FullName

The error is thrown at "Set TableName = DS.FullName"
Where TableName is IName and DS.FullName is IName.
This should not throw a Type Mismatch error but it is, and only in ArcGIS 10; all other previous versions work.
0 Kudos
5 Replies
NancyPerini
Emerging Contributor
Just trying out some of our old VBA code ArcGIS 10 and getting a type mismatch error where I should NOT be getting one.

Here is the code:
Dim DS as IDataSet
Set DS = MyTable
Dim TableName As IName         
Set TableName = DS .FullName

The error is thrown at "Set TableName = DS.FullName"
Where TableName is IName and DS.FullName is IName.
This should not throw a Type Mismatch error but it is, and only in ArcGIS 10; all other previous versions work.


HAS THERE BEEN ANY RESOLUTION TO THIS?  I'M HAVING THE SAME ISSUE.  THANKS.
0 Kudos
HalilSiddique
Frequent Contributor
Just trying out some of our old VBA code ArcGIS 10 and getting a type mismatch error where I should NOT be getting one.

Here is the code:
Dim DS as IDataSet
Set DS = MyTable
Dim TableName As IName
Set TableName = DS .FullName

The error is thrown at "Set TableName = DS.FullName"
Where TableName is IName and DS.FullName is IName.
This should not throw a Type Mismatch error but it is, and only in ArcGIS 10; all other previous versions work.


Is there any solution to this, as im having the same problem.
0 Kudos
AlexanderGray
Honored Contributor
I gave this a try on ArcGIS 10 SP5 and it worked ok...  The table was an Oracle table accessed through SDE.  In the original code, I noticed a space between the "DS" and ".FullName", probably just a copy/paste issue...  When converting VBA code from 9.3 mxds to 10, originally, I noticed that many of my references where pooched.  I had to go to tools, references and remove the missing ones, then it worked ok.  It seems VBA stops loading references as soon a it gets to a missing one, so if the one you need is after that in the list, it doesn't work.

Dim mxd As IMxDocument
Set mxd = ThisDocument
Dim map As IMap
Set map = mxd.FocusMap

Dim tabcoll As ITableCollection
Set tabcoll = map

Dim tabl As ITable
Set tabl = tabcoll.Table(0)

Dim DS As IDataset
Set DS = tabl
Dim TableName As IName
Set TableName = DS.FullName
Dim dsName As IDatasetName
Set dsName = TableName

Debug.Print dsName.Name
0 Kudos
HalilSiddique
Frequent Contributor
I gave this a try on ArcGIS 10 SP5 and it worked ok...  The table was an Oracle table accessed through SDE.  In the original code, I noticed a space between the "DS" and ".FullName", probably just a copy/paste issue...  When converting VBA code from 9.3 mxds to 10, originally, I noticed that many of my references where pooched.  I had to go to tools, references and remove the missing ones, then it worked ok.  It seems VBA stops loading references as soon a it gets to a missing one, so if the one you need is after that in the list, it doesn't work.

Dim mxd As IMxDocument
Set mxd = ThisDocument
Dim map As IMap
Set map = mxd.FocusMap

Dim tabcoll As ITableCollection
Set tabcoll = map

Dim tabl As ITable
Set tabl = tabcoll.Table(0)

Dim DS As IDataset
Set DS = tabl
Dim TableName As IName
Set TableName = DS.FullName
Dim dsName As IDatasetName
Set dsName = TableName

Debug.Print dsName.Name


Thanks for the suggestion, I've checked the references but nothing is missing. Here is the code im using

    ' Loop through the codepoint layer
    Set pDataset = pdatasets.Next
    Do While Not (pDataset Is Nothing)
        ' MsgBox (pDataset.Name)
        Select Case pDataset.Type
        Case esriDTFeatureClass
            Select Case pDataset.BrowseName
            Case "OS_VECTOR.OS_CODEPOINT"
                Set pName = pDataset.FullName ===========FAILS HERE ==============
                Set m_pCodePointClass = pName.Open
                'Set pFCcodepoint = pName.Open
                'MsgBox (pFCcodepoint.ShapeType)
            End Select
        End Select
        Set pDataset = pdatasets.Next
    Loop


I've tried your code and it does work, so I'm confused.
0 Kudos
AlexanderGray
Honored Contributor
Maybe FullName property is nothing...  I don't see the code that declares the IName variable, nor does it have the part that got the dataset enumeration.  Are you getting it from the document, the workspace, a featuredataset?  Do you have layers with broken paths, etc.
0 Kudos