By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,241 Members | 760 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,241 IT Pros & Developers. It's quick & easy.

Parameter value field in access that can be passed?

P: 29
Hello, is there a parameter value field in access that can be passed between queries, forms and reports?
For example, we have two companies both selling the same products. To extract data we have to enter the date twice, once for each company. To print a report we have to enter the date again. Is it possible to enter the date once which can be used by all the processes?
Thanks for your help.
Apr 24 '07 #1
Share this Question
Share on Google+
10 Replies


MMcCarthy
Expert Mod 10K+
P: 14,534
In a module create a Global variable to hold the date.

Expand|Select|Wrap|Line Numbers
  1. Global myDate As Date
When you enter the date set the value to this variable.

Now put a function in a module to return the date
Expand|Select|Wrap|Line Numbers
  1. Function getmyDate()
  2.  
  3.    getmyDate = myDate
  4.  
  5. End Function
  6.  
Now set this function as the criteria for the queries.

Expand|Select|Wrap|Line Numbers
  1. getmyDate()
Mary
Apr 25 '07 #2

P: 29
In a module create a Global variable to hold the date.

Expand|Select|Wrap|Line Numbers
  1. Global myDate As Date
When you enter the date set the value to this variable.

Now put a function in a module to return the date
Expand|Select|Wrap|Line Numbers
  1. Function getmyDate()
  2.  
  3.    getmyDate = myDate
  4.  
  5. End Function
  6.  
Now set this function as the criteria for the queries.
Many thanks - I shall give it a go.
Expand|Select|Wrap|Line Numbers
  1. getmyDate()
Mary
Many thanks I shall give it a go
Apr 25 '07 #3

P: 29
Many thanks I shall give it a go
Hello,
I have tried reading up on global variables without much success! I am afraid that it will take me a bit longer before I can work them out.
Thanks
Apr 25 '07 #4

MMcCarthy
Expert Mod 10K+
P: 14,534
Hello,
I have tried reading up on global variables without much success! I am afraid that it will take me a bit longer before I can work them out.
Thanks
Global Variables:

Have to be declared in a module (not a form module) as follows:
Expand|Select|Wrap|Line Numbers
  1. Global strSQL As String
  2. Global intVar As Integer
If you have a few of these you can create a module just to hold them.

Once you have declared the variable you can use it anywhere in your code

Example:

strSQL = "SELECT * FROM TableName"

You don't have to declare the variable locally with Dim.
strSQL will hold this value until you change it regardless of whether you close the form.

Mary
Apr 25 '07 #5

NeoPa
Expert Mod 15k+
P: 31,494
Global Variables:

Have to be declared in a module (not a form module) as follows:
Expand|Select|Wrap|Line Numbers
  1. Global strSQL As String
  2. Global intVar As Integer
This is perfectly correct but the recommended way of declaring the global variables is now to use the Public keyword rather than the earlier Global keyword.
They will both work at the moment (in current versions that is) but Global is earmarked for extinction.
Expand|Select|Wrap|Line Numbers
  1. Public strSQL As String
  2. Public intVar As Integer
May 1 '07 #6

MMcCarthy
Expert Mod 10K+
P: 14,534
This is perfectly correct but the recommended way of declaring the global variables is now to use the Public keyword rather than the earlier Global keyword.
They will both work at the moment (in current versions that is) but Global is earmarked for extinction.
Expand|Select|Wrap|Line Numbers
  1. Public strSQL As String
  2. Public intVar As Integer
Good to know :)
May 1 '07 #7

P: 29
Good to know :)
If I understood what you are saying I would respond:)
Regards,
Hugh
May 2 '07 #8

NeoPa
Expert Mod 15k+
P: 31,494
Don't worry about our prattle Hugh.
Do you understand enough of Mary's post to implement it?
May 2 '07 #9

P: 29
Don't worry about our prattle Hugh.
Do you understand enough of Mary's post to implement it?
Unfortunately not. I do not understand VB although I am trying to find a course. I have read a book on Access but this is fairly basic so I have a lot to learn.
Hugh
May 8 '07 #10

NeoPa
Expert Mod 15k+
P: 31,494
Try going back to post #5 Hugh.
If you find that you can't follow it, let us know where you get stuck and we can lead you from there.
May 8 '07 #11

Post your reply

Sign in to post your reply or Sign up for a free account.