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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
Thank you for your replies. I did what Marshall said, and it worked very
well. Thanks so much! Joy |
Thread Tools | |
Display Modes | |
|
|
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 |
Taher | Setting Up & Running Reports | 1 | August 31st, 2004 09:07 PM |