example using Enum in Acc2002?

  • Thread starter Thread starter Ted
  • Start date Start date
T

Ted

Greetings,

Does anyone have an example of how to use Enum in
Acc2002? I know how to delcare an Enum:

Public Enum abc
a = 1
b = 2
End Enum

But how or when would you use this? What is the purpose
of Enum vs Type variable in Access 2002?
 
Enumerations are useful where you want to hard-code a list of items to a
number.

Here's a very simple example that is kinda like using a constant instead of
trying to remember what number is each type of pet. The same thing happens
with the built in enumerations, such as vbSunday, vbMonday, ...

Enum MyList
dog = 1
cat = 2
End Enum
Public Function WhatPet(MyMember As MyList) As Integer
WhatPet = MyMember
End Function

Paste this example into a standard module.
Then open the Immediate window (Ctrl+G), and enter:
? WhatPet(
At that point, your enumeration is offered, so you don't have to remember
the code for each one.

BTW, you can also call the built-in enumerations. For example, if you need
the same code for two buttons that open a report in normal or preview, you
could create a function and declare it like this:
Function OpenTheReport(strDoc As String, lngView As acView)
and then call it like this:
Call OpenTheReport("Report1", acViewPreview)
 
Thanks very much for getting back to me on this and for
all the information and explanations. This is hot! I
will be exploiting Enum to the hilt. This is real
convenient for coding. I really can't get over Acc2002.
It has so many improvements over the previous versions,
especially in the Sql, like I can write Tsql type
statments like

Select Count(fld3) From (Select fld1, fld2, fld3 From tbl1
t1 Join tbl2 t2 On t1.fld1 = t2.fld2 Where...)

I imagine Acc2003 has even more cool stuff, but the
ultimate will be the .Net version of Access with
inheritance and stuff. Right now I have to write VB.Net
apps which have to call Access for crunching numbers (I
can't think of anything that is easier for granular
crunching of numbers and then reporting than Access).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

about enum 3
Enum TypeConverter 3
Merge Info From Two Enums 1
Enum bug? 6
Enum Extentions 7
Coding Convention for using Binary FlagWords? 3
enum type 3
[Flags] Enum -- make it better 1

Back
Top