More DoCmd methods for forms

The DoCmd object used in the example in the preceding section to open and close forms provides many methods for working with data on forms. Table 6-3 summarizes some of the more commonly used DoCmd methods for working with forms and data in forms.

Table 6-3

Commonly Used DoCmd Methods

To Do This

Use This

Move cursor to a specific control

DoCmd.

GoToControl

Select object

DoCmd.

SelectObject

Move to a specific record

DoCmd.

GoToRecord

Find a record

DoCmd.

FindRecord

Find next matching record

DoCmd.

FindNext

Filter records in a form

DoCmd.

ApplyFilter

Remove filter

DoCmd.

ShowAllRecords

Sound a beep

DoCmd.

Beep

Print form (or other object)

DoCmd.

Printout

Save form (or other object)

DoCmd.

Save

To Do This

Use This

Perform a command from the Ribbon

DoCmd.

RunCommand

Copy a form (or other object)

DoCmd.

CopyObject

Rename a form (or other object)

DoCmd.

Rename

Delete a form (or other object)

DoCmd.

DeleteObject

Send object electronically DoCmd.SendObject

Send object electronically DoCmd.SendObject

You don't need to study and memorize all these methods now because you can easily get detailed information as needed. Just type the beginning of the statement into your code, like this:

DoCmd.GoToRecord

Just double-click the method name (such as GoToRecord) to select it and then press F1.

The Object Browser, which is always available in the VBA Editor, provides another great resource for getting quick information on methods of the DoCmd object (as well as every other object in your database). To open the Object Browser in the VBA Editor, choose ViewOObject Browser from the VBA Editor's menu bar or press F2 while you're in the VBA Editor.

See Chapter 2 for more information on using the Object Browser.

After the Object Browser is open, click DoCmd in the left column. The methods that DoCmd supports are listed down the right pane. For help with a particular method, click its name in the right column and then click the Help button near the top of the Object Browser (see Figure 6-10).

DoCmd selected

Help

Figure 6-10:

Methods of the DoCmd object in the Object Browser.

^ Object Eln

Jl Libraries^

| DoCmd

Classes

Members of'DoCmd'

© DisplayUnitLabel

"0

AddMenu

DISPPARAMS

ApplyFilter

0 DistListltem

Beep

& DoCrrid

Cane el Event

JS$J Document

■sS. ClearMacroError

Document

Close

^ Documentlnspector

CloseDatabase

© Documentlnspectors

CopyDatabaseFile

Ë& Documentltem

CopyObject

© DocumentLibraryVersion

DeleteObject

© Doc umentLibra reversions

DoMenultem

DocumentProperties

Echo

DocumentProperly

FindNext

© Documents

-^iFindRecord

© Documents

sô GoToControl

© DocumenlWindow

GoToPage

© DocumenlWindows

GoToRecord

© DownBars

0

Hourglass

Class DoCmd

Member of Access

DoCmd methods

Part III

Was this article helpful?

0 0

Post a comment