Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to add custom property to the form

Status
Not open for further replies.

bobetko

Programmer
Jan 14, 2003
155
US
How can I add custom property to the form.
It need to be simple text field.

I want to do something like this:

Form1.MyPropery="MyText"

Thanks in Advance
 
I don't think there is a way to add property in Access. All properties are predefined by Bill Gates. Only him has the power to do so in his next version of Access. You need to pay big bucks to get them!!!

I don't know your use of adding a new property to a form. Can you provide more details on what would you like to accomplish. I bet there are a dozen ways to do every thing (including the wrong ways)in Access. Just let us know!!
 
I was looking around and this is what I came up with:

Private tmpVar As String
Property Let myProp(myValue As String)
'......... You can place any code here
tmpVar = myValue
End Property

Property Get myProp() As String
'......... You can place any code here
myProp = tmpVar
End Property

Private Sub Command0_Click() 'Form's button
Me.myProp = "Test" 'assign value
MsgBox (Me.myProp) 'display value
End Sub

Property Let is used to set value, and Property Get to retreive value.
Variable tmpVar is used just to exchenge value between Let and Get.

Property Let is procedure which execute when you issue Me.myProp = "some_string" (writting to property), and Property Get is procedure wich execute when you issue SomeVar = Me.myProp (reading from property)

It is working for me wery well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top