Solved! Go to Solution.
I'm glad that it works for you, and hope that you don't find my house to be in violation of irrigation codes! 🙂
BTW, here's an example on how IsPointIn() works:Sub InitilizeForm Dim objLayer 'Get a reference to the first layer Set objLayer = Application.Map.Layers("Violations") Dim objEditForm Set objEditForm = objLayer.forms("EDITFORM") Dim pControls Set pControls = ThisEvent.Object.Pages("PAGE1").Controls Dim pPt Set pPt = Application.CreateAppObject("Point") pPt.X = Map.PointerX pPt.Y = Map.PointerY 'Call when adding a new feature If objEditForm.Mode = 3 Then pControls("txtAddress").value = "" pControls("txtPIN").value = "" 'Find Address & PIN # from Parcels Layer Dim objParcels Set objParcels = Application.Map.Layers("Parcels") Dim rsGrid Set rsGrid = objParcels.Records rsGrid.movefirst Do While Not rsGrid.eof If rsGrid.Fields.Shape.Ispointin(pPt) Then pControls("txtAddress").value = rsGrid.Fields("ADDR1").Value pControls("txtPIN").value = rsGrid.Fields("PIN").Value Exit Do End If rsGrid.Movenext Loop End If Set objLayer = Nothing Set objEditForm = Nothing Set pControls = Nothing Set pPt = Nothing Set objParcels = Nothing Set rsGrid = Nothing End Sub
Thanks again! I currently have the Lat/Lon fields filled in using GPS.Latitude and GPS.Longitude. However, if they do not have a gps signal (such as in the office) and they want to add a violation based on a complaint (people call and say "soandso is watering when they are not supposed to" I would like these fields to be filled in based on where they clicked on the map.
Is it possible to grab Lat/Lon from the map and not the GPS unit?
I know about Map.PointerX/Y, but those give me state plane coordinates and I want DD. Is there a simple conversion scripts perhaps?
Thanks
... Dim pPt Set pPt = Application.CreateAppObject("Point") pPt.X = Map.PointerX pPt.Y = Map.PointerY Dim pLLCS 'define a coordinate system Set pLLCS = Application.CreateAppObject( "CoordSys" ) pLLCS.Import("C:\Program Files (x86)\ArcGIS\ArcPad10.0\Coordinate System\Geographic Coordinate Systems\World\WGS 1984.prj") Dim pDstPoint Set pDstPoint = pLLCS.Project(pPt) msgbox("the DD coordinate is " & pDstPoint.X & ", " & pDstPoint.Y) ...
Brilliant! It works flawlessly. Thank you so very much for your dedication to this community.
I am running into a new problem now!
When my field technician reopens a feature for editing (such as adding information concerning when he mailed a written warning, follow up inspection date, etc) The address and pin fields are changing to erroneous values. Is there a way to make the script run ONLY WHEN NEW FEATURES ARE CREATED and not just when the edit form loads? or is there a way to LOCK the fields once they have been filled in once? or can I make the script not fill in the attributes if there is already text in the control box?
Thanks in advance!!!
Sub InitializeForm 'Do any form initialization in this sub If objEditForm.Mode = 3 Then 'Things to do when create a new feature go here End If If objEditForm.Mode = 2 Then 'Things to do when edit an existing feature go here End If End Sub
A lot of good info here. I have a quick question along the same idea. What would it take to return the address number from parcels on each side of the parcel clicked on? For example, 123 is to the left of the clicked parcel and 127 is to the right of the clicked parcel.
Thanks and God bless!
I've been following this thread because I was trying to do something similiar and do not have any programming experience. Thank you for assiting in making a challenge less difficult for me. I was able to modify this code to accomplish what I needed to but found that I need to place my parcels shapefile into the same directory with the shapefile that I am modifying. Normally all my basemap data is located in other directories to keep them separate from data that is being collected or modified, especially since there is a lot of basemap data. I tried modifying the path to the location where the parcels reside but that resulted in an error, source object not found. My question, how do I modify the script to point to my directory where my parcels are located, or is that not possible?
Parcels reside in C:\GIS\Shapefiles\Parcels\Polygons\Parcels.shp
The line below is the one that currently works as long as the parcels reside in the same directory:
Set objParcels = Application.Map.Layers("Parcels")
Thanks.