Results 1 to 6 of 6

Thread: "User defined type not defined" error

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2001
    Location
    lexington,ky.u.s.a
    Posts
    8

    "User defined type not defined" error

    Hi,
    I am gettin the "User defined type not defined" error at this point in the code

    Private Function AppendFields(CurMap As MapObjects2.Map, CurLegend As MO2legend.legend, NewRecordset As ADODB.Recordset, colParameters As Collection)

    I thought its cos i am not providing reference for adodb, even after addin the reference ,error still persists. does collection object need any reference? Could you please tell me what might be going wrong?

    Thanks

    Karunya

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Mak sure you've added whatever references you need to use MapObjects2 and MO2legend.
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2001
    Location
    lexington,ky.u.s.a
    Posts
    8
    Thanks for the suggestion.The error still persists.can u suggest somethin else?

    thanks
    karunya

  4. #4
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    That may not be the actual line of error. Look in your project references and components and make sure nothing is marked "MISSING".
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  5. #5
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    Let's see the code...
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  6. #6

    Thread Starter
    New Member
    Join Date
    Nov 2001
    Location
    lexington,ky.u.s.a
    Posts
    8
    Hi,
    This is the code. When the error appears, the "Public Sub AppendFields(CurMap As MapObjects2.Map, CurLegend As MO2legend.legend, NewRecordset As ADODB.Recordset, colParameters As Collection)" is highlighted. Let me know guys if u can make out somethin from this.It will be of great help to me

    Thanks
    karunya

    Public Sub AppendFields(CurMap As MapObjects2.Map, CurLegend As MO2legend.legend, NewRecordset As ADODB.Recordset, colParameters As Collection)

    Dim lyr As MapObjects2.MapLayer
    Dim tDesc As MapObjects2.TableDesc
    Dim dc As MapObjects2.DataConnection, cn As ADODB.Connection
    Dim str As String, lyrpath As String, lyrname As String

    'Initialize the active layer
    Set lyr = CurMap.Layers(CurLegend.getActiveLayer)

    'Verify the field name, if it already exist in the shapefile table
    Dim VerRes As MapObjects2.Recordset
    Set VerRes = lyr.Records

    Dim x As Integer, Y As Integer
    For Y = 1 To colParameters.Count
    For x = 0 To VerRes.TableDesc.FieldCount - 1
    If colParameters.Item(Y) = VerRes.TableDesc.FieldName(x) Then
    MsgBox "The field is already exist in the target shapefile, please specify another unique name", vbOKOnly, "Watshman -- Information"
    Exit Sub
    End If
    Next x
    Next Y

    Set VerRes = Nothing

    frmMeasurement.MousePointer = 11

    'Take away the string "[Shapefile]" & filename, the reason has them is they can be easily used
    'for address matching
    lyrpath = Left(lyr.Tag, (Len(lyr.Tag) - Len(lyr.Name) - 1))
    lyrpath = Right(lyrpath, (Len(lyrpath) - 11))
    lyrname = lyr.Name

    CurMap.Layers.Remove (CurLegend.getActiveLayer)

    Set dc = New MapObjects2.DataConnection
    Set tDesc = New MapObjects2.TableDesc
    dc.Database = lyrpath

    Dim tempFileName As String
    tempFileName = "Temp" & Int((1000 * Rnd) + 1) 'Rondom append a number to "temp" string
    Set lyr.GeoDataset = dc.AddGeoDataset(tempFileName, moShapeTypePoint, tDesc)

    CurMap.Refresh

    Set cn = New ADODB.Connection

    cn.Open "Driver={Microsoft Visual Foxpro Driver};SourceType=DBF;SourceDB=" & lyrpath

    'Add columns according to the number of parameters in the ResFinal recordset
    Dim i As Integer
    Dim strTemp As String 'The temp string for each parameter name for each added column

    NewRecordset.MoveFirst
    cn.BeginTrans

    For i = 1 To colParameters.Count

    strTemp = VerifyName(colParameters.Item(i)) 'Validate string
    strTemp = Left(strTemp, 8)

    str = "ALTER TABLE " & lyrname & " ADD COLUMN " & strTemp & " NUMERIC(16,3)"
    cn.Execute (str)
    NewRecordset.MoveNext
    Next i
    cn.CommitTrans

    'Update field values
    Dim m As Integer, n As Integer
    strTemp = "" 'Reset data manipulation SQL string
    str = ""

    cn.BeginTrans
    NewRecordset.MoveFirst

    'Update each field(Parameter) by referencing the current record
    For m = 1 To NewRecordset.RecordCount
    strTemp = VerifyName(colParameters.Item(i)) 'Validate string
    strTemp = Left(strTemp, 8)

    str = "UPDATE " & lyrname & " SET " & strTemp & " = " & NewRecordset.Fields("AvgOfvalue").Value & " WHERE Feature_ID = " & CLng(NewRecordset.Fields("FeatureID").Value)
    cn.Execute (str)

    If Not NewRecordset.EOF Then
    NewRecordset.MoveNext
    End If
    Next m
    cn.CommitTrans

    dc.DeleteGeoDataset (tempFileName)

    'Add to layer's tag, this gonna used for address matching
    Set lyr = New MapObjects2.MapLayer
    Set lyr.GeoDataset = dc.FindGeoDataset(lyrname)
    lyr.Tag = "[SHAPEFILE]" & lyrpath & "|" & lyrname

    CurMap.Layers.Add lyr

    dc.Disconnect
    cn.Close
    Set dc = Nothing
    Set cn = Nothing

    frmMeasurement.MousePointer = 0
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width