I would to know if it is possible to write generic functions to set properties on form.fields
A quick example to show what I mean :
Instead of
Me!FieldA.BackColor = 255
Me!FieldB.BackColor = 255
...
Sort of substitution :
SetBackColor("FieldA")
SetBackColor("FieldB")
Function SetBackColor(Fieldname)
Me!%Fieldname%.BackColor=255
End Function
The %Fieldname% dynamically replaced by FieldA FieldB
The example doesn't make very much sense, it's only purpose is to show the idea.
Are there any possibilities to realize such a solution ?
Thx
3 1685
Hi, there.
It looks like you don't like OOP. ;)
Or you just wanted to ask "how can I pass to my function reference to object?"
Anyway I have a good news - reference to object may be passed to sub/function just like any other variable.
Example: -
Public Sub SetBkColor(ByRef txbTarget As Access.TextBox, _
-
ByVal lngColor as Long)
-
txbTarget.BackColor = lngColor
-
End Sub
-
then in form module -
SetBkColor Me.txtSomething, 255
-
or taking into account that several control types have BackColor property, something like this -
Public Sub SetBkColor(ByRef objTarget As Variant, _
-
ByVal lngColor as Long)
-
On Error Resume Next
-
objTarget.BackColor = lngColor
-
End Sub
-
then in form module -
SetBkColor Me.cboSomething, 255
-
Regards,
Fish
Hi, there.
It looks like you don't like OOP. ;)
Or you just wanted to ask "how can I pass to my function reference to object?"
Anyway I have a good news - reference to object may be passed to sub/function just like any other variable.
Example: -
Public Sub SetBkColor(ByRef txbTarget As Access.TextBox, _
-
ByVal lngColor as Long)
-
txbTarget.BackColor = lngColor
-
End Sub
-
then in form module -
SetBkColor Me.txtSomething, 255
-
or taking into account that several control types have BackColor property, something like this -
Public Sub SetBkColor(ByRef objTarget As Variant, _
-
ByVal lngColor as Long)
-
On Error Resume Next
-
objTarget.BackColor = lngColor
-
End Sub
-
then in form module -
SetBkColor Me.cboSomething, 255
-
Regards,
Fish
Hi Fish,
Sure I like OOP, the problem is that I'm writing a system with a dozen of forms and a huge number of fields, which need all the same formatting and conditional testing. It would be a great waste of time (and resources) to do that over-and-over for any of them.
Thank you very much for your input, it's exactly what I was looking after. Great ! :-)
Greetz
Walter
Glad, it helped you.
Good luck and happy coding.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Jim Newton |
last post by:
hi all, i'm relatively new to python. I find it a
pretty interesting language but also somewhat limiting
compared to lisp. I notice that the language does
provide a few lispy type nicities, but...
|
by: Roman Suzi |
last post by:
Hi,
I wonder, does Python support generic programming paradigm, and to what extent
(I guess, it doesn't do it in full)? And (or) does it move in that direction?
Will we ever see
concept...
|
by: Leslaw Bieniasz |
last post by:
Cracow, 20.10.2004
Hello,
As far as I understand, the generic programming basically consists
in using templates for achieving a static polymorphism of the
various code fragments, and their...
|
by: Lauren Quantrell |
last post by:
Hoping someonce can tell me what compatibility problems I might run
into when I have to have my Access Project developed on Access2K run
in a user environment where users are using Access2003 as...
|
by: 2D Rick |
last post by:
With the help from members in the VB forum I've pieced together code
that works in VB6 to create radial text similar to "text on a path"
seen in graphics programs.(on a circle only)
I use an...
|
by: usenet |
last post by:
How and where can one find out about the basics of VB/Access2003
syntax?
I am a died in the wool C/C++/Java Linux/Unix programmer and I am
finding it difficult to understand the program format...
|
by: deependrapathak |
last post by:
Hi All,
I am currently facing a crutial problem in Access2003 in Windows XP on just 3 PCs, the Application throws some of the errors specified below :
1. Error Number : 3075 Function is not...
|
by: Ramchandar |
last post by:
Hi,
I am creating reports using VBA code.
I have the same query in a querydef residing both in Access97 and Access2003. The result of this querydef is then moved to a table in Access97 and...
|
by: raylopez99 |
last post by:
Here is a good example that shows generic delegate types. Read this
through and you'll have an excellent understanding of how to use these
types. You might say that the combination of the generic...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |