Form B Opens

Chamber Application - Development

Business

Susirïes's Harme First Name: First Name 2:

Street: City;

Telephone. Email. Website: Susirïes's' Type: Member Since:

Susirïes's Harme First Name: First Name 2:

Street: City;

Telephone. Email. Website: Susirïes's' Type: Member Since:

|Armeri

Last Name:

Stein

1 Steve

Last Name 2.

Sent:f¡

14IÜ44 14Stri Ave NE

I Redmond

State |WA

Zip Code: |

1425-869-0797

Fax: I

District; J

j Status^.

CUR

3 Í Non Profit Flag

Payments

Date

Amoun

i

3/7/2003

$150. LIO

4/1/2001

$300 00

*

Figure I-3

When Form B wakes up, it has a little housekeeping to do before anything else happens. In the On Open event, it needs to remember the name of the form that called it. Later, when Form B closes, it will use that name to make Form A visible again.

Private Sub Form_Open(Cancel As Integer) On Error GoTo Error_Handler

Me.Caption = AppGlobal.ApplicationNameAndDB() mstrCallingForm = gstrCallingForm gstrCallingForm = ""

Exit_Procedure:

Exit Sub Error_Handler:

MsgBox "An error has occurred in this application. " _ & "Please contact your technical support person and tell them this information:" _

& vbCrLf & vbCrLf & "Error Number " & Err.Number & ", " & Err.Description, _

Buttons:=vbCritical, title:="My Application"

Resume Exit_Procedure Resume End Sub

To remember the name, the value in gstrCallingForm is placed safely into mstrCallingForm.

mstrCallingForm = gstrCallingForm

This module level variable (indicated with the "m" prefix) is declared at the top of the Form B's module, like this:

Option Compare Database

Option Explicit

Dim mstrCallingForm As String

Notice that gstrCallingForm is set to an empty string right after its contents are saved into mstrCallingForm:

gstrCallingForm = ""

There is no programming logic reason for doing this; it's really just a message to other programmers that we are completely done with using the global variable, so we are clearing its value. It has done its job well (for the last few milliseconds) and can go back to being an empty string now that it has transferred its contents to the local module variable.

At this point, Form B is ready to continue opening and perform whatever functions it is designed to do. It will remember the name of the calling Form A until Form B closes.

Was this article helpful?

0 0

Post a comment