[mso] Re: Access VC setting Variables

  • From: "Colli, Anthony G" <Anthony.Colli@xxxxxxx>
  • To: "'mso@xxxxxxxxxxxxx'" <mso@xxxxxxxxxxxxx>
  • Date: Tue, 7 Jan 2003 10:07:01 -0500

In Access forms and reports have their own modules. The events of a form or
report, or the events of a control on a form or report, are executed in the
form or report module. 

You can also create a module to contain public items like classes and
functions. If you wanted a function to be available to all your forms you
can insert a new module and add the code there. 

Global variables, declared outside of a form or report module, are also
available to all modules. 

If I need to use a global variable I will usually do this. Create a new
module and name it mod_Start. In mod_Start declare all my global variables,
and set them to a value. Create a macro and name it autoexec. In the
autoexec macro have it run some code in mod_Start. This way all the globals
are now available, initialized, and all in one place. If I need a new global
variable I'll only put it in mod_Start, to keep things neat and tidy.

-Anthony




-----Original Message-----
From: April Pace [mailto:4office@xxxxxxxxxxxxx]
Sent: Monday, January 06, 2003 4:55 PM
To: mso@xxxxxxxxxxxxx
Subject: [mso] Re: Access VC setting Variables



Ok thanks...

Now I am a little confused about what defines a Module... In excel, I can
put code for more than one spreadsheet into the same "Module"... From what I
am figuring out in Access the code for each form is it own "Module"  I am I
correct??

Also,

I want to define the strVariable in a "macro/coding" on the main form
frmClientInfo, then read what the strVariable is on sfrmResponContact Form
when It unloads it....  (It is populating a one of two field on my main
form, and depending on which field prompted the sfrmResponContact Form to
open...

So do I Put the:

Option Explicit
Dim strVariable As String

on just the top of the frmClientInfo code page or on both forms??

Thanks, April
-----Original Message-----
From: mso-bounce@xxxxxxxxxxxxx [mailto:mso-bounce@xxxxxxxxxxxxx]On
Behalf Of Colli, Anthony G
Sent: Monday, January 06, 2003 9:46 AM
To: 'mso@xxxxxxxxxxxxx'
Subject: [mso] Re: Access VC setting Variables


April-

 To create a global variable that is available to all the subs and functions
in your form module, on the very top of the form modules code there is
'Option Compare Database', add a global variable under that line. like:

Option Compare Database
Option Explicit
Dim strVariable As String

strVariable is now available to all the code in that module. Global
variables like this are usually set in the 'Onload' event of the form. You
can also work with them from other forms and modules.

Be cautious using globals. If you have many forms, you might create globals
with the same name, Access does not like this.

-Anthony



-----Original Message-----
From: April Pace [mailto:4office@xxxxxxxxxxxxx]
Sent: Sunday, January 05, 2003 4:23 PM
To: Office (E-mail)
Subject: [mso] Access VC setting Variables


Help...... If you have been following my posting I have a form that if they
click on a button it will open another form....


I have a Client Info Form
Mailing Address
Billing Address
Contact/Responsible Party Form

The Contact & Responsible person and be one and the same or two different
persons... Since it can be one and the same I have both on one form....

Ok, so here is what I have done and am trying to do:

If they click that they need to add an Responsible Party,  I have figured
out how to get what ever name they put on the Contact/Responsible Form to
populate my main form (which is still open) in the ResponsibleName field.
Now if they specify that the contact name is the same as the Responsible
Party Name, then it will automatically populate the Contact Name field with
the same name was the Responsible Party Name field.... But if they specify
that the Contact name is DIFFERENT from the Responsible Party's Name then
the Contact/Responsible Form will re open so they can add the Contact
Name.... Ok here is what I need to figure out.....

I want to create a variable on my main form tblClientInfo at the place where
it calls the Contact/Respon Form to open... I want the variable
WhoCalledForm  where I can say WhoCalledPartyForm="Responsible" or
WhoCalledForm="Contact"

Then on the tblContact/Responsible I want to do the following:


Private Sub CommandClose_Click()

On Error GoTo Err_CommandClose_Click

If WhoCalledForm  = "Responsible" Then

    Me.txtCltResponName.SetFocus            'set the focus on the form to
Me.txtCltResponName
    Forms!frmClientInfo.txtCltResponName = Me.txtCltResponName 'set the
value of Me.txtCltResponName

ElseIf WhoCalledForm  = "Contact" Then

    Me.txtCltResponName.SetFocus
    Forms!frmClientInfo.txtCltContactName = Me.txtCltResponName

End If


    DoCmd.Close
Exit_CommandClose_Click:
    Exit Sub

Err_CommandClose_Click:
    MsgBox Err.Description
    Resume Exit_CommandClose_Click

End Sub


I tried on the Main Form Dim WhoCalledForm  as String, I also tried Public
WhoCalledForm  as string (But after the Private Sub cbxContRespon_Click() )
and the other form could not see the variable....


How do I (Or were) do I state a "public" Variable so that the code above
will work

April



*************************************************************
You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or
MicrosoftOffice@xxxxxxxxxxxxxxxx

To send mail to the group, simply address it to mso@xxxxxxxxxxxxx

To Unsubscribe from this group, send an email to
mso-request@xxxxxxxxxxxxx?Subject=unsubscribe

Or, visit the group's homepage and use the dropdown menu.  This will also
allow you to change your email settings to digest or vacation (no mail).
//www.freelists.org/webpage/mso

To be able to use the files section for sharing files with the group, send a
request to mso-moderators@xxxxxxxxxxxxx and you will be sent an invitation
with instructions.  Once you are a member of the files group, you can go
here to upload/download files:
http://www.smartgroups.com/vault/msofiles
*************************************************************


*************************************************************
You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or
MicrosoftOffice@xxxxxxxxxxxxxxxx

To send mail to the group, simply address it to mso@xxxxxxxxxxxxx

To Unsubscribe from this group, send an email to
mso-request@xxxxxxxxxxxxx?Subject=unsubscribe

Or, visit the group's homepage and use the dropdown menu.  This will also
allow you to change your email settings to digest or vacation (no mail).
//www.freelists.org/webpage/mso

To be able to use the files section for sharing files with the group, send a
request to mso-moderators@xxxxxxxxxxxxx and you will be sent an invitation
with instructions.  Once you are a member of the files group, you can go
here to upload/download files:
http://www.smartgroups.com/vault/msofiles
*************************************************************

*************************************************************
You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or
MicrosoftOffice@xxxxxxxxxxxxxxxx

To send mail to the group, simply address it to mso@xxxxxxxxxxxxx

To Unsubscribe from this group, send an email to 
mso-request@xxxxxxxxxxxxx?Subject=unsubscribe

Or, visit the group's homepage and use the dropdown menu.  This will also
allow you to change your email settings to digest or vacation (no mail).
//www.freelists.org/webpage/mso

To be able to use the files section for sharing files with the group, send a
request to mso-moderators@xxxxxxxxxxxxx and you will be sent an invitation
with instructions.  Once you are a member of the files group, you can go
here to upload/download files:
http://www.smartgroups.com/vault/msofiles
*************************************************************


*************************************************************
You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or 
MicrosoftOffice@xxxxxxxxxxxxxxxx

To send mail to the group, simply address it to mso@xxxxxxxxxxxxx

To Unsubscribe from this group, send an email to 
mso-request@xxxxxxxxxxxxx?Subject=unsubscribe

Or, visit the group's homepage and use the dropdown menu.  This will also allow 
you to change your email settings to digest or vacation (no mail).
//www.freelists.org/webpage/mso

To be able to use the files section for sharing files with the group, send a 
request to mso-moderators@xxxxxxxxxxxxx and you will be sent an invitation with 
instructions.  Once you are a member of the files group, you can go here to 
upload/download files:
http://www.smartgroups.com/vault/msofiles
*************************************************************

Other related posts: