One Variable in many programs

  • Thread starter Afrosheen via AccessMonster.com
  • Start date
A

Afrosheen via AccessMonster.com

Thanks for reading this.
What I'd like to do if it can be done is to declare all my variables in a
module public function and be able to use them in other programs. For example.


Option Compare Database
Option Explicit
Public head1, strdocname, stLinkCriteria, stwhere, stwhere1, stwhere2,
stwhere3, stwhere4, shft, strUser, Text8, strcnt As String
Public head2, head3, head4, stDocname1, stdocname2, stdocname3 As String
Public userpermission As Integer

One example is the head1 sting. It is used as an openargs statement, but in
different programs.
These variables are used within 3-4 programs. Do you see any problem using
them like this?

What I'm trying to do is cut back in code programming and make the programs
smaller.

Thanks.
I hope I've explained my self .
 
A

Afrosheen via AccessMonster.com

Hi Alex and thanks for the respond.
Here is an example. I'm using the ptforms routine once in this program. Once
in A_Rotation_Click() and B_Rotation_Click() when I click on that button

Private Sub A_Rotation_Click()
10 On Error GoTo Err_A_Rotation_Click

head1 = "A-Days Post Report"
head2 = "For A-Days"
head3 = "A-Nights Post Report"
head3 = "For A-Night"
prtforms
endsub

Then I'm calling a print routine from within this program

Private Sub ptforms()

170 DoCmd.OpenReport strdocname, acNormal, , stwhere, , head1
180 DoCmd.OpenReport stdocname2, acNormal, stwhere2, , head2
190 DoCmd.OpenReport strdocname, acNormal, , stwhere3, , head3
200 DoCmd.OpenReport stdocname2, acNormal, , stwhere4, , head4
210 DoCmd.OpenReport stdocname3, acNormal
220 DoCmd.OpenReport stDocname1, acNormal, , stwhere1

End Sub

The head1, head2, head3, head4 are the variables that were declared in the
Module

Alex said:
Hi
do you mean procedures (sub and funtions)(? then yes - you can use public
variable among them
Thanks for reading this.
What I'd like to do if it can be done is to declare all my variables in a
[quoted text clipped - 20 lines]
Thanks.
I hope I've explained my self .
 
A

Alex Dybenko

Hi,
yes, this should work

--
Best regards,
___________
Alex Dybenko (MVP)
http://accessblog.net
http://www.PointLtd.com


Afrosheen via AccessMonster.com said:
Hi Alex and thanks for the respond.
Here is an example. I'm using the ptforms routine once in this program.
Once
in A_Rotation_Click() and B_Rotation_Click() when I click on that button

Private Sub A_Rotation_Click()
10 On Error GoTo Err_A_Rotation_Click

head1 = "A-Days Post Report"
head2 = "For A-Days"
head3 = "A-Nights Post Report"
head3 = "For A-Night"
prtforms
endsub

Then I'm calling a print routine from within this program

Private Sub ptforms()

170 DoCmd.OpenReport strdocname, acNormal, , stwhere, , head1
180 DoCmd.OpenReport stdocname2, acNormal, stwhere2, , head2
190 DoCmd.OpenReport strdocname, acNormal, , stwhere3, , head3
200 DoCmd.OpenReport stdocname2, acNormal, , stwhere4, , head4
210 DoCmd.OpenReport stdocname3, acNormal
220 DoCmd.OpenReport stDocname1, acNormal, , stwhere1

End Sub

The head1, head2, head3, head4 are the variables that were declared in the
Module

Alex said:
Hi
do you mean procedures (sub and funtions)(? then yes - you can use public
variable among them
Thanks for reading this.
What I'd like to do if it can be done is to declare all my variables in
a
[quoted text clipped - 20 lines]
Thanks.
I hope I've explained my self .
 
A

Afrosheen via AccessMonster.com

Thank for your reply and help. I really appreciate it.



Alex said:
Hi,
yes, this should work
Hi Alex and thanks for the respond.
Here is an example. I'm using the ptforms routine once in this program.
[quoted text clipped - 37 lines]
 
Top