making the constants for an paramater drop down in a custom function?

  • Thread starter Thread starter kelly d via AccessMonster.com
  • Start date Start date
K

kelly d via AccessMonster.com

What do I have to do to get a list of constants to drop down as I enter the
values into my own custom functions kinda like how a list of constants drop
down when you use the built in functions like docmd.openform, for example,
when you enter the view paramater you get a list of constants to choose from
and when you enter the datamode paramater you get another list of constants
to choose from ect. or any of the other functions that give you a list of
constants to choose from. how does one do that?
thanks
Kelly D
 
You can do this if you declare the argument as the data type that the
constants belong to.

Example:
Function OpenTheReport(strDoc As String, View as acView)

Since acView is the name of the name of the Class that contains
acViewPreview, acViewNormal, etc, then Access will drop down that list of
constants as you type your arguments for this function.

To find the name of the class you need, open the Object Browser (F2 from a
code window), and search on one of the constants.

There is a working example of this OpenTheReport() function downloadable
from this article:
http://allenbrowne.com/AppPrintMgt.html
It requires Access 2002 or 2003.
 
What do I have to do to get a list of constants to drop down as I
enter the values into my own custom functions kinda like how a list of
constants drop down when you use the built in functions like
docmd.openform


put this in a module:

public enum tfColour
tfColourRed
tfColourBlue
tfColourGreen
end enum

public Function ColourToRGB(SomeColour As tfColour)
Select Case SomeColour
Case tfColourRed : ColourToRGB = RGB(255,0,0)
Case tfColourBlue : ColourToRGB = RGB(0,255,0)
Case tfColourGreen : ColourToRGB = RGB(0,0,255)
End select

End Function



now type something like this in another module:

frm.backgroundcolor = ColourToRGB(

and you will get a popup with a list of the available tfColour values.

Hope that makes it clear!

Tim F
 
Wow! this must have been a good question. I got the big dogs answering me
this time! :)

Thanks Allen and Tim, your answers were right on the money. I've spent the
last handful of hours scouring the internet for an answer. I've found alot of
good, unrelated, info but nothing close to the answers you guys gave me.

thanks
Kelly D
 
Back
Top