473,386 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

storing a variable

I want to give the user the ability to change a setting.

Example Discount rate = .4

value stored in record 1 tblSettings.Discount

the user will be able to change the value through a form that only
allows modifying record 1.

How do I pass this value to a module and then refer to it in queries,
forms and reports.

David
Nov 12 '05 #1
5 10882
In the form where the user is updating the value of Discount, you can
use the form as the container for the value. It sounds like you want to
use this value as a parameter in your queries, forms, reports. You can
refer to the form in your queries as follows:

In a query design view, in the field which you want to filter with this
value/parameter, goto the criteria row of that field and type something
like this:

Forms!yourForm!Text1

yourForm is the form where the user is updating the value (the form name
- it could be frmDiscount and you would write

Forms!frmDiscoutn!Text1

)
Text1 is the control where the user is entering/updating the value.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #2

"david" <le******@sympatico.ca> wrote in message
news:ff************************@posting.google.com ...
I want to give the user the ability to change a setting.

Example Discount rate = .4

value stored in record 1 tblSettings.Discount

the user will be able to change the value through a form that only
allows modifying record 1.

How do I pass this value to a module and then refer to it in queries,
forms and reports.

David


It sounds like you want to store this one single variable for your whole
application. Although I can't think of a time when I've needed a _discount_
setting across the whole application, I often have similar variables like
MyCompany, MyAddress, MyPhone, etc so these settings can be printed out on
reports.
I do this by having a table tblDbInfo with one row and use
var=DLookup("[MyCompany]","tblDbInfo","[ID]=1") to extract this information.

Variations on this basic theme involve writing a public function to do the
lookup, or setting a global variable at application startup (this approach
needs some caution)

Hope this gives you an idea

Fletcher


Nov 12 '05 #3
Tom
For queries, just add TblSettings to your query, do not join TblSettings to
anything and pull down the discount field into the query grid. TblSettings by
not being joined to anything will form a cartesian product with the rest of your
query but since there is only one record in TblSettings you end up with the same
number of records as what the rest of your query would return if TblSettings was
not included in the query.

To display the discount rate directly on a form or report, add a field and put
this expression in the Control Source property of the textbox:

=DLookup("[Discount]","TblSettings")

PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
www.pcdatasheet.com

"david" <le******@sympatico.ca> wrote in message
news:ff************************@posting.google.com ...
I want to give the user the ability to change a setting.

Example Discount rate = .4

value stored in record 1 tblSettings.Discount

the user will be able to change the value through a form that only
allows modifying record 1.

How do I pass this value to a module and then refer to it in queries,
forms and reports.

David



Nov 12 '05 #4
I want to give the user the ability to change a setting.
Example Discount rate = .4
value stored in record 1 tblSettings.Discount Variations on this basic theme involve writing a public >function to do

the lookup, or setting a global variable at >application startup (this
approach needs some caution)

Thanks for your help

How do I create a function or global variable based on the value of a
record in a table.

David
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #5
"David Berniker" <le******@sympatico.ca> wrote in message
news:3f***********************@news.frii.net...
I want to give the user the ability to change a setting.
Example Discount rate = .4
value stored in record 1 tblSettings.Discount

Variations on this basic theme involve writing a public >function to do

the lookup, or setting a global variable at >application startup (this
approach needs some caution)

Thanks for your help

How do I create a function or global variable based on the value of a
record in a table.

David

Create a new module and write a function like the following:

Public Function GlobalDiscount() As Single
GlobalDiscount = CSng(Nz(DLookup("[Discount]", "tblSettings", "[ID]=1"),
0))
End Function

To define a global variable just put this in your new module:
Public g_sngDiscount As Single
But since you would have to set it at application startup and make sure it
was updated as necessary, in this case you would probably be better off
getting live data by calling the function each time - ie forget about a
global variable.
Fletcher
Nov 12 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: chris | last post by:
Hello, I am currently writing a simulation system which involves a large number of C++ classes, many of which contain pointers to other objects. I need the ability to save the state of the...
7
by: Snyke | last post by:
Well my problem is simple: I have a class which has a variable number of members. Lets say I have a class Family and a variable number of FamilyMembers. Until now I used a member of Family called...
4
by: matevz bradac | last post by:
Hi, I'm trying to implement delayed function execution, similar to OpenGL's display lists. It looks something like this: beginList (); fcn1 (); fcn2 ();
14
by: Luiz Antonio Gomes Pican?o | last post by:
How i can store a variable length data in file ? I want to do it using pure C, without existing databases. I'm thinking to use pages to store data. Anyone has idea for the file format ? I...
5
by: - Steve - | last post by:
I have a website that uses forms based authentication. In the logon.aspx page a user enters a username and password. It is then authenticated against Active Directory. After that point on any...
2
by: prasanthag | last post by:
Hi, I am a newbie to this group. I have a problem in handling the variable arguments passed to a function. My requirement is like this. I have 2 functions say, void funcX(int i, int j);...
3
by: prasanthag | last post by:
Hi, I am a newbie to this group. I have a problem in handling the variable arguments passed to a function. My requirement is like this. I have 2 functions say, void funcX(int i, int j);...
10
by: John Salerno | last post by:
If I want to have a list like this: where the first part of each tuple is a variable name and the second part is a label for the user to see, such as a form like this: First Name: ________...
5
by: Nandadulal | last post by:
would anyone tell me when we take a variabel suppose int a; is it create a memory space? when we access a variable with oject .variablename how it shows the value .please, tell how it works in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.