View Single Post

  #6 (permalink)  
Old 01-09-2008
looney_doc looney_doc is offline
Junior Member
White Belt
 
Join Date: Jan 2008
Posts: 6
Re: Advice Please... Access Code works but could be improved

Hello Wilfried,

thanx for your reply.

My problem with using ImportData from an Access Table from the currently used database, is the error "unable to connect to database".

I thought it to be a problem before even trying to import Data into the MapPoint Datasets.
Perhabs there's a problem with my declaration part??

I posted my code just below, perhabs it is easy to see.

Quote:
Public Function Georef()

Dim KH As Object
Dim db As Database
Dim cn As ADODB.Connection
Dim objApp As New MapPoint.Application
Dim objMap As MapPoint.Map
Dim objDataSet As MapPoint.DataSet
Dim objPat As MapPoint.DataSet 'Patientenverteilung
Dim objShp As MapPoint.Shape
Dim objLoc As MapPoint.Location
Dim objAdj As MapPoint.Adjustments
Dim objField As MapPoint.Field
Dim Adresse, DSM As String
Dim objRecordset As MapPoint.Recordset
Dim objSym As MapPoint.Symbol
Dim ImportArray(1, 1)
Dim Pfad As String

On Error GoTo GeorefError

'reading Data for georeference
Set db = CurrentDb
Set KH = db.OpenRecordset("KH-Daten", dbOpenDynaset)
KH.MoveFirst
objApp.Visible = True
objApp.UserControl = True
Set objMap = objApp.ActiveMap
Adresse = KH![KH-Strasse] & "+" & Str(KH![KH-PLZ]) & "+" & KH![KH-Ort]
Set objLoc = objMap.FindAddressResults(KH![KH-Strasse], KH![KH-Ort], , , Str(KH![KH-PLZ]), geoCountryGermany)(1)
objApp.ActiveMap.AddPushpin objLoc, KH![KH-Name]
objApp.ActiveMap.DataSets(1).Name = KH![KH-Name]
objApp.ActiveMap.DataSets(1).Symbol = 298
objApp.ActiveMap.DataSets.ZoomTo

'initialising Importarray
ImportArray(0, 0) = "PLZ"
ImportArray(1, 0) = "Anzahl"
ImportArray(1, 1) = geoFieldInformation

'Set cn = New ADODB.Connection
'cn.Open (CurrentProject.Connection)

Pfad = db.Name & "\MAA_LS.mdb!maa_Patientenherkunft"
Set objPat = objApp.ActiveMap.DataSets.ImportData(Pfad, ImportArray, geoCountryGermany, 0, geoImportAccessTable)


objApp.ActiveMap.Saved = -1 'MapPoint fragt nicht nach speichern der Karte

Exit Function

GeorefError:
MsgBox Err.Description, vbCritical, "Fehler"
End Function
Thanx for your help!
Reply With Quote