By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,504 Members | 1,584 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,504 IT Pros & Developers. It's quick & easy.

Class or Function that lists options

P: n/a
We are wondering if there is a way to write a function, or perhaps a
class, that can do the following. When you start to type a built-in
Access function, when you start to type the function, you are prompted
for each parameter that needs to be passed. Often, you get a list of
choices (acPreview, acNormal etc.). Can we create this type of thing
in our own user defined functions? I know a class will show the
properties available in the class, but what we want to do seems to be
another level of choices.

For example, we found and worked with the class below. Now, lets say
the user starts to type CalculateSunrise.city. We'd like him to see
the list of available cities. Of course, we can do this on a form with
combo boxes but is there a way we can make it part of the class?
' ------ Class clsSunRiseSet
' Version 2.01
Option Explicit
Public frm As Form
' -- The following properties are exposed:
'Sunrise (r) - Sunrise time
'Sunset (r) - Sunset time
'SolarNoon (r) - Solar noon
'
'CityCount (r) - Number of cities
'CityName (r) - Name of city, by index
'City (w) - Sets the longitude/latitude/timezone based off a city
' name or city index
'TimeZone (r/w) - Current Timezone
'DaySavings (r/w) - Daylight savings time in effect
'Longitude (r/w) - Longitude to calculate for
'Latitude (r/w) - Latitude to calculate for
''DateDay (r/w) - Date to calculate for
''
' -- The following method is exposed
'CalculateSun - Calculate sunrise, sunset and solar noon
'
' Scott Seligman
' http://www.scottandmichelle.net/scott/
' Based off of
' http://www.srrb.noaa.gov/highlights/sunrise/gen.html

Nov 13 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
I believe what you are looking for is Enum. Read up on the Enum.

On 13 Dec 2004 20:51:59 -0800, "Penguin" <rh*********@yahoo.com> wrote:
We are wondering if there is a way to write a function, or perhaps a
class, that can do the following. When you start to type a built-in
Access function, when you start to type the function, you are prompted
for each parameter that needs to be passed. Often, you get a list of
choices (acPreview, acNormal etc.). Can we create this type of thing
in our own user defined functions? I know a class will show the
properties available in the class, but what we want to do seems to be
another level of choices.

For example, we found and worked with the class below. Now, lets say
the user starts to type CalculateSunrise.city. We'd like him to see
the list of available cities. Of course, we can do this on a form with
combo boxes but is there a way we can make it part of the class?
' ------ Class clsSunRiseSet
' Version 2.01
Option Explicit
Public frm As Form
' -- The following properties are exposed:
'Sunrise (r) - Sunrise time
'Sunset (r) - Sunset time
'SolarNoon (r) - Solar noon
'
'CityCount (r) - Number of cities
'CityName (r) - Name of city, by index
'City (w) - Sets the longitude/latitude/timezone based off a city
' name or city index
'TimeZone (r/w) - Current Timezone
'DaySavings (r/w) - Daylight savings time in effect
'Longitude (r/w) - Longitude to calculate for
'Latitude (r/w) - Latitude to calculate for
''DateDay (r/w) - Date to calculate for
''
' -- The following method is exposed
'CalculateSun - Calculate sunrise, sunset and solar noon
'
' Scott Seligman
' http://www.scottandmichelle.net/scott/
' Based off of
' http://www.srrb.noaa.gov/highlights/sunrise/gen.html


Nov 13 '05 #2

P: n/a
You are asking for an enumeration:

Enum MyList
dog = 1
cat = 2
End Enum
Public Function TestMyList(MyMember As MyList)
Debug.Print MyMember
End Function

BTW, you can also use the built-in enumerations, e.g.:
Dim Response As VbMsgBoxResult

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Penguin" <rh*********@yahoo.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
We are wondering if there is a way to write a function, or perhaps a
class, that can do the following. When you start to type a built-in
Access function, when you start to type the function, you are prompted
for each parameter that needs to be passed. Often, you get a list of
choices (acPreview, acNormal etc.). Can we create this type of thing
in our own user defined functions? I know a class will show the
properties available in the class, but what we want to do seems to be
another level of choices.

For example, we found and worked with the class below. Now, lets say
the user starts to type CalculateSunrise.city. We'd like him to see
the list of available cities. Of course, we can do this on a form with
combo boxes but is there a way we can make it part of the class?
' ------ Class clsSunRiseSet
' Version 2.01
Option Explicit
Public frm As Form
' -- The following properties are exposed:
'Sunrise (r) - Sunrise time
'Sunset (r) - Sunset time
'SolarNoon (r) - Solar noon
'
'CityCount (r) - Number of cities
'CityName (r) - Name of city, by index
'City (w) - Sets the longitude/latitude/timezone based off a city
' name or city index
'TimeZone (r/w) - Current Timezone
'DaySavings (r/w) - Daylight savings time in effect
'Longitude (r/w) - Longitude to calculate for
'Latitude (r/w) - Latitude to calculate for
''DateDay (r/w) - Date to calculate for
''
' -- The following method is exposed
'CalculateSun - Calculate sunrise, sunset and solar noon
'
' Scott Seligman
' http://www.scottandmichelle.net/scott/
' Based off of
' http://www.srrb.noaa.gov/highlights/sunrise/gen.html

Nov 13 '05 #3

P: n/a
Thanks for your responses. Unfortunately, enum is not available in
Access 97. From various searches it would appear that one can declare
constants, but how can you get them to show up in intellisense?

I also tried to look at dim abc as combobox or as dropdown - but there
didn't seem to be much info. Would this help me?

Nov 13 '05 #4

P: n/a
On 16 Dec 2004 20:18:46 -0800, "Penguin" <rh*********@yahoo.com> wrote:
Thanks for your responses. Unfortunately, enum is not available in
Access 97. From various searches it would appear that one can declare
constants, but how can you get them to show up in intellisense?

I also tried to look at dim abc as combobox or as dropdown - but there
didn't seem to be much info. Would this help me?


You didn't say it was Access 97. I don't think yuo can do it without making
an ActiveX library on VB6.
Nov 13 '05 #5

P: n/a
Penguin wrote:
We are wondering if there is a way to write a function, or perhaps a
class, that can do the following. When you start to type a built-in
Access function, when you start to type the function, you are prompted
for each parameter that needs to be passed. Often, you get a list of
choices (acPreview, acNormal etc.). Can we create this type of thing
in our own user defined functions? I know a class will show the
properties available in the class, but what we want to do seems to be
another level of choices.

For example, we found and worked with the class below. Now, lets say
the user starts to type CalculateSunrise.city. We'd like him to see
the list of available cities. Of course, we can do this on a form with
combo boxes but is there a way we can make it part of the class?


No, there is no enum in A97.

I did this by creating public methods for every constant. It is not the
same as intellisense, as you still have to type the class name (using
the generic reference)

CalculateSunrise.city = clsSunRiseSet.

and a list of methods including the constants follows. You could even
have a separate class (possibly with a shorter name) containing just
those constants, exposed as methods.

--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea
Nov 13 '05 #6

P: n/a
All I have is VB4 (and no help on it either!) I assume since you
mention VB6 that I can't do it in VB4?

Nov 13 '05 #7

P: n/a
On 17 Dec 2004 07:51:08 -0800, "Penguin" <rh*********@yahoo.com> wrote:
All I have is VB4 (and no help on it either!) I assume since you
mention VB6 that I can't do it in VB4?


That is correct. I think it might be possible in VB5, but I'm not certain.
Nov 13 '05 #8

P: n/a
I don't have VB4 to test, but Enum may have been introduced after that.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Penguin" <rh*********@yahoo.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
All I have is VB4 (and no help on it either!) I assume since you
mention VB6 that I can't do it in VB4?

Nov 13 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.