2009-06-30 128 views
0

我有一個常規的形式稱爲「魚」。它有一個名爲「loctree」的TreeCtl,我用它作爲位置選擇器來改變Fish中的字段。訪問2003年VBA:自定義窗體屬性問題

我已經向Fish添加了幾個子表單。其中兩個有我想使用loctree的位置字段。由於我不想爲每個子表單實例化一個新的TreeCtl,所以我想我可以讓loctree知道它的當前目標是哪個控件。我以爲來定義當前的目標將是一個屬性添加到我的魚形式最簡單的方法:

Option Compare Database 

Private locfield As Field 

Property Let loc_focusField(target As Field) 
    locfield = target 
End Property 

Property Get loc_focusField() 
    loc_focusField = locfield 
End Property 

然後在魚的形式打開事件,我可以設置locfield的默認值:

Private Sub Form_Open(Cancel As Integer) 
    locfield = Forms!fish_moves!fish_moves_loc_id 
End Sub 

不幸的是,每次我嘗試打開我的形式,我得到以下錯誤時間:

Definitions of property procedures for the same property are inconsistent, or property procedure has an optional parameter, a ParamArray, or an invalid Set final parameter

那麼是什麼原因?

感謝, 仁

回答

3

IIRC,你的屬性應該像

Property Set loc_focusField(target As Field) 
    set locfield = target 
End Property 

Property Get loc_focusField() as Field 
    set loc_focusField = locfield 
End Property 

運作的?