2012-08-28 29 views
0

我使用以下腳本從一個圖層獲取宗地和地址信息,以填充新創建的要素的屬性表。ArcPad - VBscript - Autopopulate屬性

沒有返回錯誤,但我遇到的問題是,似乎有錯誤的信息卡在記錄選擇功能的內存中。無論我在哪裏放置一個點,它都會給出相同的包裹#和地址。或者,也許它實際上不是正確執行IF功能。

Sub Address 

Dim rsCurrentXY 
Set rsCurrentXY = Map.Layers("Violations").records 
rsCurrentXY.movelast 
Dim objXYShape 
Set objXYShape = rsCurrentXY.Fields.Shape 
Dim pControls 
Set pControls= Application.Map.selectionlayer.Forms("EDITFORM").Pages(「PAGE1」).Controls 
Dim rsGrid 
' Find corresponding map page to the valve point 
Set rsGrid = Map.Layers("ACPA_parcels").records 
rsGrid.movefirst 

Do While Not rsGrid.eof 
If rsGrid.fields.shape.Ispointin(objXYShape) Then 
pControls("txtAddress").value = rsGrid.Fields("ADD1").Value 

Exit Do 
End If 
rsGrid.Movenext 
Loop 


' Clean Up 
Set rsCurrentXY = Nothing 
Set objXYShape = Nothing 
Set rsGrid = Nothing 
End Sub 

(我有一個名爲「PIN」另一個子程序,會做同樣的事情。) 我當自定義窗體各自的編輯框檢查員激活叫他們。

感謝您的幫助, 羅伯特

回答

0

訪問通過Application.Map.selectionlayer.Forms的EDITFORM( 「EDITFORM」)將是有問題的。每當使用EDITFORM上的控件時,您應該使用ThisEvent.Object來發現所有對象。例如,如果您的事件處理程序是Page_OnLoad,那麼ThisEvent.Object將引用您當前的頁面。你應該有這樣的代碼:

Dim pPage1 
Set pPage1 = ThisEvent.Object 
Dim pControls 
Set pControls = pPage1.Controls 
+0

http://forums.arcgis.com/threads/65742-Filling-in-atrributes-for-a-point-layer-from-a-underlying-polygon-layer ?p = 228353&posted = 1#post228353 – user1631426

+0

http://forums.arcgis.com/threads/65742-Filling-in-atrributes-for-a-point-layer-from-a-underlying-polygon-layer?p=228353&posted = 1#post228353 – user1631426