Danni
I recently did something similar but I am at this stage a bit of a
hacker (as in I'm not very good at it).
I do not need to open to arcmap and then zoom as I already have it
open when I go to a particular zoom.
But to open it with a map use something like this:
fullpath2 = "D:\Data\crash\ crash analysisBASIC.m xd"
Call ShellExecute(0, vbNullString, "D:\Data\crash\ crash
analysisBASIC.m xd", vbNullString, fullpath2, 1)
The most 'dodgy' thing about what I have done is that it uses
clipboard to paste a string from Access and then ArcMap grabs this
string and uses it as a query, then zooms to what it finds.
In access have a text box with your query made: ie "LandID = 5000"
Then have a button with an event:
'Incase the user makes another copy by accident this button recopies
the query
'string to clipboard
txtSelectObject sQuery.SetFocus
If IsNull(txtSelec tObjectsQuery) = False Then
DoCmd.RunComman d acCmdCopy
Else
MsgBox "There must be text in the query text box to copy", _
vbExclamation + vbOKOnly + vbDefaultButton 1, "No String
" & _
"to Copy!"
End If
Make a form in arcMap called frmQueryStringH older and save it to
normal.mxd
Now on a button you have created in ArcMap:
Private Sub FindIntersectio n_Click()
Dim str As String
frmQueryStringH older.txtSQLStr ing.SetFocus
frmQueryStringH older.txtSQLStr ing.Text = ""
frmQueryStringH older.txtSQLStr ing.Paste
'MsgBox frmQueryStringH older.txtSQLStr ing.Text
Call ThisDocument1.F indIntersection (frmQueryString Holder.txtSQLSt ring.Text)
End Sub
Now in a module named thisdocument1 put:
Option Explicit
Dim pMxApp As IMxApplication
Dim pMxDoc As IMxDocument
Private Declare Function sndPlaySound32 Lib "winmm.dll" Alias
"sndPlaySou ndA" (ByVal lpszSoundName As String, ByVal uFlags As Long)
As Long
Public Sub FindIntersectio n(strQuery As String)
On Error GoTo FindIntersectio nError:
Set pMxApp = Application
Set pMxDoc = ThisDocument
Dim pMap As IMap
Set pMap = pMxDoc.FocusMap
Dim pFLayer As IFeatureLayer
'Set pFlayer = pMap.Layers(0)
Dim i As Integer
For i = 0 To pMap.LayerCount - 1
If pMap.Layer(i).N ame = "IntersectL GA" Then
Set pFLayer = pMap.Layer(i)
End If
Next i
Dim pqfilter As IQueryFilter
Set pqfilter = New QueryFilter
pqfilter.WhereC lause = strQuery
Debug.Print pqfilter.WhereC lause
Dim pWS As IWorkspace
Dim pDS As IDataset
Set pDS = pFLayer.Feature Class
Set pWS = pDS.Workspace
'Dim pFselSet As ISelectionSet
'Set pFselSet = pFlayer.Feature Class.Select(pq filter,
esriSelectionTy peHybrid, esriSelectionOp tionNormal, pWS)
'Debug.Print pFselSet.Count
Dim pFSel As IFeatureSelecti on
Set pFSel = pFLayer
pFSel.SelectFea tures pqfilter, esriSelectionRe sultNew, False
Dim pSelSet As ISelectionSet
Set pSelSet = pFSel.Selection Set
Dim pEnvelope As IEnvelope
Dim pFcurs As IFeatureCursor
Dim pFeat As IFeature
If pSelSet.Count > 1 Then
Dim pEnumGeom As IEnumGeometry
Dim pEnumGeomBind As IEnumGeometryBi nd
Set pEnumGeom = New EnumFeatureGeom etry
Set pEnumGeomBind = pEnumGeom
pEnumGeomBind.B indGeometrySour ce Nothing, pSelSet
Dim pGeomFactory As IGeometryFactor y
Set pGeomFactory = New GeometryEnviron ment
Dim pGeom As IGeometry
Set pGeom = pGeomFactory.Cr eateGeometryFro mEnumerator(pEn umGeom)
pMxDoc.ActiveVi ew.Extent = pGeom.Envelope
ElseIf pSelSet.Count = 1 Then
pSelSet.Search Nothing, True, pFcurs
Set pFeat = pFcurs.NextFeat ure
Set pEnvelope = pFeat.Extent
Debug.Print pEnvelope.Width
pEnvelope.Width = pEnvelope.Width + 1
pEnvelope.Heigh t = pEnvelope.Heigh t + 1
pEnvelope.Expan d 50, 50, True
Debug.Print pEnvelope.Width
pMxDoc.ActiveVi ew.Extent = pEnvelope
Else
MsgBox "error"
End If
pMxDoc.ActiveVi ew.Refresh
'zoom out a little
Dim pActiveView As IActiveView
Dim pDisplayTransfo rm As IDisplayTransfo rmation
Dim pCenterPoint As IPoint
Set pActiveView = pMxDoc.FocusMap
Set pDisplayTransfo rm =
pActiveView.Scr eenDisplay.Disp layTransformati on
Set pEnvelope = pDisplayTransfo rm.VisibleBound s
'In this case, we could have set pEnvelope to IActiveView::Ex tent
'Set pEnvelope = pActiveView.Ext ent
Set pCenterPoint = New Point
pCenterPoint.X = ((pEnvelope.XMa x - pEnvelope.XMin) / 2) +
pEnvelope.XMin
pCenterPoint.Y = ((pEnvelope.YMa x - pEnvelope.YMin) / 2) +
pEnvelope.YMin
pEnvelope.Width = pEnvelope.Width * 1.1
pEnvelope.Heigh t = pEnvelope.Heigh t * 1.1
pEnvelope.Cente rAt pCenterPoint
pDisplayTransfo rm.VisibleBound s = pEnvelope
pActiveView.Ref resh
FindIntersectio nError:
If Err.Number = -2147467259 Then
MsgBox "The WHERE clause of the SQL statement comes from " & _
"clipboard. Please ensure the clipboard contains a valid " & _
"WHERE clause.", vbExclamation + vbOKOnly + _
vbDefaultButton 1, "SQL Error"
Exit Sub
Else
'MsgBox "Error Number " & Err.Number & " - " & Err.Description
End If
Call sndPlaySound32( "G:\RS&NM\RS\CR ASH\RequestsDB\ dogbark4.wav", 0)
End Sub
You'll have to change the code as usual to suit your needs. Most
importantly set the layer from "IntersectL GA" to what your layers name
is. This code combine's the geometries of objects if more than one
object is selected. It also for fun plays a dog barking sound file so
we know its found it - Corny hey.
Good luck. It may get you by
Lincoln King
Sydney, Australia
"danit58" <da*****@tiscal inet.it> wrote in message news:<cj******* ***@lacerta.tis calinet.it>...
Anyone use il software ESRI ArcView GIS?????
In a DB Access I store information about plot of land, house and related
ownership.
By click a button in a specific record, I want to open ESRI ArcView with a
specific view: the selected object in access, is selected in the map in view
Who help me???
By Dany