Both Access and VBA contain another structure called an enum. Short for enumeration, this structure is a wrapper of sorts for a group of built-in constants—more of a way to categorize constants than actually do anything with them. You won't actually use the enum to do anything; rather, you'll use the constants declared within the enum instead of using their intrinsic values. Access has a number of built-in enums. The following enum describes the various constants that can be used to specify the view of a form.

-SS Microsoft Visual Basic - VBA Samples - [Samples (Code)]

Eile Edit View [use it Debug

Projecl ■


m a :

S *

j ¥BA Samples (VI

] Microsoft Office

1 Modules

Module 1



] Class Modules


■ ■

Properties - SampE

Samples Module Alphabetic Categorized

Samples Module Alphabetic Categorized

j Start

Figure 4-5

j (General I

Run lools All(1-1 lis Window Help lype a question for lielp ill! H K I Of S? * I ® Ln 131, Col 46 I

▼ j j OpenDatahaseConnection strState strState


InputBox("Please enter a state"


strConn = "Provider=Micro3of t. Jet. OLEDB . 4 , Ü ; Data Source=c : ) Dataliia3e3\Addres|

st.rSQL - "SELECT [Cust.omerWaine] , [Cust.omerCode] , [Cust.oinerAddre331] " _ s "., [Cust.omerCity] , [CustomerState) , [Cust.omerZip] FROH" _ í "Customers WHERE [CustomerState] is Wot Hull;"

st.rSQL = "Select * from t.tol Cus tornera WHERE Cust.omerState objConn.Open (strConn) objConn.Mode = adModeRead objRST,Open st.rSQL, objConn, adOpenForwardOnly, adLock:Opt.imist.ic objRST. MoveFir3t.

El jvljAljiiiKetrviyrioie

E vtiApplicationMociai Iii vbCrltlcal ! S vbDefaultButton l

While Wot ObjRST,EOF

txtCust.omerState = oto j RST. F ield3 ( "Custcj1 txtCust.omerZip ■ objRST. Fields ( "Customs ' If (txtCust.omerSt.ate - "CA" And txtCust E vbDefaultButtonS (txtCust.omerState = "WA" And txt.Custriiiir txtCust.omerRegion = "West.ernUS" msgbox("Western US Customer Updated", End Mstj&oxtPrompf, [Briltojis As VliMsyBoxSlyle = vbOKOnly], [Tj'f/el, [HeipFiie], [Context) AS VbMsoBoxRasull

: m vbDeísultButton3 '3 vbDe*aullButton4

j Start

Figure 4-5

Enum AcFormView

acNormal = O

acDesign = 1

acPreview = 2

acFormDS = 3


= 4


= 5

End Enum

You can browse any of the Access or VBA enums through the use of the Object Browser. We'll cover the Object Browser in Chapter 5.

Was this article helpful?

0 0

Post a comment