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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Public Constants in Public Functions? 3

Status
Not open for further replies.

jordanking

Programmer
Sep 8, 2005
351
Hello,

I was wondering if there is a way to include an option list of public constants in the declaration of public functions?

I have a public function with constants declared:
Code:
Public Const ActionInsert As Integer = 1
Public Const ActionUpdate As Integer = 2
Public Const ActionDelete As Integer = 5
Public Const ActionImport As Integer = 6 
Public Const ActionExport As Integer = 7
Public Const ActionCascadeUpdate As Integer = 8
Public Const ActionCascadeDelete As Integer = 9
Public Const ActionInvoice As Integer = 10

Public Function uf_Audit(intRecord As Integer, intRecTp As Integer, intAction As Integer, strDetail As String, frm As Form) As Integer
etc.....

I want to have the above constants appear as options for the "intAction" varaible when the function is called, like when you open a recordset and the following options appear once you enter the coma after the connection variable. (i hope that makes sense)
adOpenDynamic
adOpenForwardOnly
adOpenKeyset
adOpenStatic


Is this possible?
 
SOLUTION:

This is how I got it to work:

Code:
Option Compare Database
Option Explicit

'''Action Types
Public Enum DMS_Action
     DMS_Insert = 1
     DMS_Update = 2
     DMS_Delete = 5
     DMS_Import = 6
     DMS_Export = 7
     DMS_CascadeUpdate = 8
     DMS_CascadeDelete = 9
     DMS_Invoice = 10
End Enum

'''Record Types

Public Function DMS_Audit(intRecord As Integer, intRecTp As Integer, intAction As DMS_Action, strDetail As String, frm As Form) As Integer

the enum options jump up on screen once the calling of the public function get to that variable.
 




Thanks!

Skip,
[sub]
[glasses] When a diminutive clarvoyant had disappeared from detention, headlines read...
Small Medium at Large[tongue][/sub]
 
Nice!

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
I like that!


Cheers, Glenn.

Did you hear about the literalist show-jumper? He broke his nose jumping against the clock.
 
one thing to note,

as far as i can tell, the results from enum are returned as long values, with no way to change that. You would have to do your type conversions within the public function.
 




Yes, I just discovered, when trying to retrofit an existing function, using a string argument.

My designs will be better in the future.

Skip,
[sub]
[glasses] When a diminutive clarvoyant had disappeared from detention, headlines read...
Small Medium at Large[tongue][/sub]
 
Skip,

I tried to create an array of string constants, and a custom public type including strings and/or string constants, neighter would work.

As far as I know enum is just an array, I wonder if there is a way to get another array to behave this way?



 
A custom public type could work in a similar way, though not the same. The question of using types other than long's interested me so I was having a crack at it while at work earlier, I'll pick it up again when I get back and see what I can come up with.

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top