A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Using Public Variables in my Query



 
 
Thread Tools Display Modes
  #1  
Old March 19th, 2005, 05:00 AM
Joy
external usenet poster
 
Posts: n/a
Default Using Public Variables in my Query

Hi -

There are 2 public variables in my program.
Public curKilometerRate As Currency
Public curHSTRate As Currency

I have a subform called frmInstructorExpenseDetailsExtendedSUBF
based on the query called qryExpenseDetailsExtended

I need to use the public variables in several columns of my query.
for example KMExpense: KMValue*curKilometerRate
where KMValue was entered by the user and curKilometerRate is a public
variable.

(I cannot use a parameter box, the value of curKilometerRate is read in from
outside the program into a public variable.)

Any 'step by step' instructions on how to do this will be greatly
appreciated. I have already spent a lot of time reading the newsgroups and
implementing various suggestions - but I haven't been successful.

Thank you for your time. I appreciate your helping me.

Joy


  #2  
Old March 19th, 2005, 05:17 AM
Ken Snell [MVP]
external usenet poster
 
Posts: n/a
Default

Create a public function that returns the value of the public variable. Use
the public function in your query.

--

Ken Snell
MS ACCESS MVP

"Joy" wrote in message
...
Hi -

There are 2 public variables in my program.
Public curKilometerRate As Currency
Public curHSTRate As Currency

I have a subform called frmInstructorExpenseDetailsExtendedSUBF
based on the query called qryExpenseDetailsExtended

I need to use the public variables in several columns of my query.
for example KMExpense: KMValue*curKilometerRate
where KMValue was entered by the user and curKilometerRate is a public
variable.

(I cannot use a parameter box, the value of curKilometerRate is read in
from outside the program into a public variable.)

Any 'step by step' instructions on how to do this will be greatly
appreciated. I have already spent a lot of time reading the newsgroups
and implementing various suggestions - but I haven't been successful.

Thank you for your time. I appreciate your helping me.

Joy



  #3  
Old March 19th, 2005, 05:18 AM
Duane Hookom
external usenet poster
 
Posts: n/a
Default

Create public functions that returns each variable:
Public Function GetKilRate() as Currency
GetKilRate = curKilometerRate
End Function
You can then use GetKilRate() where ever you need the value.

--
Duane Hookom
MS Access MVP


"Joy" wrote in message
...
Hi -

There are 2 public variables in my program.
Public curKilometerRate As Currency
Public curHSTRate As Currency

I have a subform called frmInstructorExpenseDetailsExtendedSUBF
based on the query called qryExpenseDetailsExtended

I need to use the public variables in several columns of my query.
for example KMExpense: KMValue*curKilometerRate
where KMValue was entered by the user and curKilometerRate is a public
variable.

(I cannot use a parameter box, the value of curKilometerRate is read in
from outside the program into a public variable.)

Any 'step by step' instructions on how to do this will be greatly
appreciated. I have already spent a lot of time reading the newsgroups
and implementing various suggestions - but I haven't been successful.

Thank you for your time. I appreciate your helping me.

Joy



  #4  
Old March 19th, 2005, 05:38 AM
Marshall Barton
external usenet poster
 
Posts: n/a
Default

Joy wrote:
There are 2 public variables in my program.
Public curKilometerRate As Currency
Public curHSTRate As Currency

I have a subform called frmInstructorExpenseDetailsExtendedSUBF
based on the query called qryExpenseDetailsExtended

I need to use the public variables in several columns of my query.
for example KMExpense: KMValue*curKilometerRate
where KMValue was entered by the user and curKilometerRate is a public
variable.

(I cannot use a parameter box, the value of curKilometerRate is read in from
outside the program into a public variable.)

Any 'step by step' instructions on how to do this will be greatly
appreciated. I have already spent a lot of time reading the newsgroups and
implementing various suggestions - but I haven't been successful.



Variables exist only in the VBA environment. The only VBA
items that are known to the Access and SQL name spaces are
public functions.

Add a function for each variable to the module containing
the variables:

Public curKilometerRate As Currency
Public curHSTRate As Currency

Public Function GetKilometerRate()
GetKilometerRate = curKilometerRate
End Function

Public Function GetHSTRate()
GetHSTRate = curHSTRate
End Function

Then your query can use expressions like:
KMExpense: KMValue * GetKilometerRate()

--
Marsh
MVP [MS Access]
  #5  
Old March 19th, 2005, 10:44 PM
Joy
external usenet poster
 
Posts: n/a
Default

Thank you for your replies. I did what Marshall said, and it worked very
well.
Thanks so much!

Joy


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Parameter query - nested queries laura Running & Setting Up Queries 3 February 10th, 2005 04:09 PM
Moving from xBase/Clipper [email protected] New Users 1 February 3rd, 2005 07:25 PM
Financial Comparison Steven Cheng Setting Up & Running Reports 13 November 26th, 2004 10:59 PM
Print Taher Setting Up & Running Reports 1 August 31st, 2004 09:07 PM


All times are GMT +1. The time now is 11:51 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.