Access: The Switchboard Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

'------------------------------------------------------------
' OpenMovieFrm_Click
'
'------------------------------------------------------------

Private Sub OpenMovieFrm_Click()
On Error GoTo OpenMovieFrm_Click_Err

DoCmd.OpenForm "Movies", acNormal, "", "", , acNormal


OpenMovieFrm_Click_Exit:
Exit Sub

OpenMovieFrm_Click_Err:
MsgBox Error$
Resume OpenMovieFrm_Click_Exit

End Sub

Database Tools ->Visual Basic

The DO command

This is a very, very busy user interface. Focus on the code. It is the big window on the right side.

 

The code begins with: Private Sub

It must finish with: End Sub

"Sub" means subroutine.

 

The action of opening a form is:

DoCmd.OpenForm stDocName

 

DoCmd is the method.

OpenForm is the command we chose with the Wizard.

"Movies" is the name of the form you are opening.

 

Error Trapping

The rest of the code looks for errors. If you spelled the name of the form wrong, the subroutine would catch your mistake and bring up a message box.

 

Error trapping is a good thing. It keeps the program from running around in circles (an endless loop) or crashing.