Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Results 1 to 4 of 4

Creating Recordset

This is a discussion on Creating Recordset within the MapPoint Desktop Discussion forums, part of the Map Forums category; Please help! I've been struggling for weeks! I've tried a thousand ways to create a recordset and the closest i've ...

  1. #1
    sugarflux is offline Junior Member White Belt
    Join Date
    Feb 2007
    Posts
    6

    Creating Recordset

    Please help! I've been struggling for weeks!

    I've tried a thousand ways to create a recordset and the closest i've got is receiving the error 'permission denied'. I say the closest because this would indicate that the coding is correct but something else has gone wrong?

    Ideally i would like to return a list of postcode sectors within a 20 mile drivetime of a full postcode. However, at present i would be happy to return anything postcode related in a recordset.

    From my searching, the most basic recordset should be possible from the below. This returns the 'Permission Denied' error.

    Set objMap = objapp.ActiveMap
    Set objDataSet = objMap.DataSets.GetDemographics(geoCountryUnitedKi ngdom)

    Set rst = objDataSet.QueryAllRecords

    Thanks for your help,
    sugarflux

  2. #2
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433

    Re: Creating Recordset

    Hi,

    Which line is offending ? The QueryAllRecords, or the GetDemoGraphics ?

  3. #3
    Paul Larson is offline Senior Member Green Belt
    Join Date
    Sep 2005
    Location
    Battle Creek, Michigan
    Posts
    136

    Arrow Re: Creating Recordset

    The error is because all the query methods return an error when used on a dataset created by a demographic.

    To rectify this, you'll need to create a pushpin map for postcode districts, then draw your radius on the selected location, then call QueryShape().

    I created a postcode district text file for you, posted at
    PostalDistricts.txt
    which you'll want to import as a pushpin map.

    After that map is loaded, you can use the following VB6/VBA routine to get the postcode districts within a radius of a searched postcode.

    Code:
    Private Function GetPostalDistrictsWithinRadius( _
            ByVal strPostalCode As String, _
            ByVal Radius As Single) As String()
        Dim locCtr As MapPoint.Location
        Set locCtr = objMap.FindAddressResults( _
            , , , , strPostalCode, "United Kingdom")(1)
        locCtr.GoTo
        objMap.Altitude = Radius + 1
        objMPApp.Units = geoMiles
        Dim shp As MapPoint.Shape
        Set shp = objMap.Shapes.AddShape( _
            geoShapeRadius, locCtr, Radius, Radius)
        shp.Line.ForeColor = 1
        shp.Line.Weight = 0.25
        shp.Fill.Visible = False
        Dim ds As MapPoint.DataSet
        Set ds = objMap.DataSets(1)
        Dim rs As MapPoint.Recordset
        Set rs = ds.QueryShape(shp)
        Dim strPCD() As String
        Dim i As Integer
        Do While Not rs.EOF
            i = i + 1
            ReDim Preserve strPCD(i)
            strPCD(i) = rs.Location.Name
            rs.MoveNext
        Loop
        shp.Delete
        GetPostalDistrictsWithinRadius = strPCD
    End Function

    You can call the method and iterate through the returned results using something like

    Code:
    Private Sub Command1_Click()
        Dim s() As String
        s = GetPostalDistrictsWithinRadius(Text1.Text, 20)
        Dim t As Variant
        For Each t In s
            Debug.Print t
        Next
    End Sub
    HTH
    Paul

  4. #4
    sugarflux is offline Junior Member White Belt
    Join Date
    Feb 2007
    Posts
    6

    Re: Creating Recordset

    Thanks Paul. I really appreciate your help.

    This looks great - just a couple of minor problems.

    First off, i need to be working at sector level. I was under the impression that i wouldn't need an external file to work with - surely these postcodes are already present in Mappoint ??

    Secondly if it is the case that the file needs importing to work with the recordset, do you have any code for importing programmatically please?

    I have tried the following:

    Set objDataSet = objApp.ActiveMap.DataSets.ImportData("C:\PostalDis tricts.txt", 1, geoCountryUnitedKingdom, geoDelimiterComma, 0)

    and receive the error:
    Cannot connect with the specified datasourcemoniker...

    Thanks again for your help,

    sugarflux

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Order a recordset?
    By Shecky in forum MapPoint Desktop Discussion
    Replies: 3
    Last Post: 10-15-2004, 08:52 PM
  2. ordering recordset
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 11-11-2003, 04:05 AM
  3. ADO Recordset Import?
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 3
    Last Post: 09-10-2003, 07:55 AM
  4. Deriving a recordset from a mappoint recordset
    By RichardHayes in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 09-06-2002, 03:44 AM
  5. ADO recordset
    By Monique in forum Wish List
    Replies: 0
    Last Post: 08-14-2002, 10:35 AM

Tags for this Thread

Posting Permissions

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


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96