Create Custom Properties For Forms or Class Modules

Create Custom Properties For Forms or Class Modules

Have you ever wanted to push a variable onto a form without using atag? Property functions let you create custom properties for forms or classmodels. Use PropertySet, PropertyGet, and PropertyLet statements to manipulatecustom properties. For example, you want to send a key value to a form so that the keyis there in time for an SQL query to use it in a condition. Include a variabledeclaration for the property as a form-level variable:

 Private msKey as String

Then add two procedures for PropertySet and PropertyLet for the form:

 Public Property Let GetKey(vNewValue)	msKey = vNewValueEnd PropertyPublic Property Get GetKey()	GetKey = msKeyEnd Property

You can now set the property from elsewhere by using:

 Form1.GetKey = "David"

In your form, use the variable you declared for any usage in your code.Property Procedures can be a bit more complex. But, the point is that theVB4 has become much more adaptable to your needs. Customize it to fit.

Share the Post:
data observability

Data Observability Explained

Data is the lifeblood of any successful business, as it is the driving force behind critical decision-making, insight generation, and strategic development. However, due to its intricate nature, ensuring the

Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular