473,811 Members | 2,565 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to fill a bound textbox automatically?

Hi there

Does anyone know how to fill a bound textbox automaticlly.

In an unbound textbox I would put in the control source =Sum(price, tax) (or
some such function) and access updates it automaticlly.

Is there a way to do the same thing on a bound textbox so that it is
automaticly updated?

Thank you kindly for your efforts
Have a great day!
John Sheppard
Nov 12 '05 #1
5 14549
Use the AfterUpdate event procedure of the controls it depends on. For
example:

Private Sub price_AfterUpda te
Me.[SomeControl] = Me.price + Me.tax
End Sub

If what you are trying to do is as simple as that example, there is a better
way yet. Remove the calcuation from the table, and put it in a query. In the
query, enter a calculated field like this into the Field row of the grid:
Amount:[price]+[tax]
Now use the query as the RecordSource for your form. The Amount field takes
care of updating itself.

The best part is that since the calculation is done when needed, you never
have to worry about whether the Amount field in your table could be wrong.
This principle - not storing dependant data - is one of the basic rules of
data normalization.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html

"John Sheppard" <jt************ @nobosospam.com .au> wrote in message
news:3f******** **************@ news.optusnet.c om.au...
Hi there

Does anyone know how to fill a bound textbox automaticlly.

In an unbound textbox I would put in the control source =Sum(price, tax) (or some such function) and access updates it automaticlly.

Is there a way to do the same thing on a bound textbox so that it is
automaticly updated?

Thank you kindly for your efforts
Have a great day!
John Sheppard

Nov 12 '05 #2
"John Sheppard" <jt************ @nobosospam.com .au> wrote in message
news:3f******** **************@ news.optusnet.c om.au...
Hi there

Does anyone know how to fill a bound textbox automaticlly.

In an unbound textbox I would put in the control source =Sum(price, tax) (or
some such function) and access updates it automaticlly.

Is there a way to do the same thing on a bound textbox so that it is
automaticly updated?

Thank you kindly for your efforts
Have a great day!
John Sheppard


Sounds like you're attempting to store a calculated value. There is seldom a good
reason to do this. Just use an expression on your forms, reports, and queries to do
the calculation on-the-fly and remove the field from your table.
Nov 12 '05 #3
ab************* **@bigpond.net. au (Allen Browne) wrote in
<Sn************ *******@news-server.bigpond. net.au>:
Use the AfterUpdate event procedure of the controls it depends on.
For example:

Private Sub price_AfterUpda te
Me.[SomeControl] = Me.price + Me.tax
End Sub
Another alternative way of doing the same thing is:

Me!SomeControl = Me!price + Me!tax

I recommend against using the dot operator for anything other than
form properties and methods, and using the ! operator for controls
and fields in the underlying recordset.
If what you are trying to do is as simple as that example, there
is a better way yet. Remove the calcuation from the table, and put
it in a query. In the query, enter a calculated field like this
into the Field row of the grid:
Amount:[price]+[tax]
Now use the query as the RecordSource for your form. The Amount
field takes care of updating itself.

The best part is that since the calculation is done when needed,
you never have to worry about whether the Amount field in your
table could be wrong. This principle - not storing dependant data
- is one of the basic rules of data normalization.


In regard to tax, I think it's always a good idea to store the tax
amount in the record, as opposed to the tax *rate*, because when
you calculate the tax amount from the rate, you may have rounding
errors that will have to be addressed every time you calculate the
total. If you store the tax *amount*, you do the rounding only
once.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 12 '05 #4
"David W. Fenton" <dX********@bwa y.net> wrote in message
news:93******** *************@2 4.168.128.78...
In regard to tax, I think it's always a good idea to store the tax
amount in the record, as opposed to the tax *rate*, because when
you calculate the tax amount from the rate, you may have rounding
errors that will have to be addressed every time you calculate the
total. If you store the tax *amount*, you do the rounding only
once.


I've always store the amount rather than the rate, and for the same reasons.
Recently I've begun to question whether this is still justified.

Strictly, we are denomalizing when we store the amount of tax, as it is
dependant on the amount of the transaction. As processor power increases,
the number of cases where denormalization makes sense decreases. What we did
in dBase III on a PC with no hard disk and 128*K* of RAM is not always
appropriate today.

Storing the tax rate and calcuating on the fly means:
1. Store the rate per row, since countries have specific items that are
tax-ex.
2. Use a query as the source for forms/reports, to include the calculated
field (tax amount).
3. The calculated field must be explicitly typecast to Currency. (*No*
calculated field can be trusted without typecasting.)
4. Currency cannot be Null, so the calcuation must involve Nz().
5. The row must be rounded to prevent apparent addition errors if the client
wants to see the tax-inc amount on each row.

Result:
TaxAmount: Round(CCur(Nz([Quantity] * [UnitPrice] * [TaxRate],0)), 2)

The question is whether processor speed now justifies performing such a
calcuation at every row of the invoice in preference to storing the
denomalized tax amount. Guess we should run some timing trials to find out.
Variables would include processor type/speed, local verses networked, JET
verses MSDE.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Nov 12 '05 #5
"Allen Browne" <ab************ ***@bigpond.net .au> wrote in
news:js******** ***********@new s-server.bigpond. net.au:
"David W. Fenton" <dX********@bwa y.net> wrote in message
news:93******** *************@2 4.168.128.78...
In regard to tax, I think it's always a good idea to store
the tax amount in the record, as opposed to the tax *rate*,
because when you calculate the tax amount from the rate, you
may have rounding errors that will have to be addressed every
time you calculate the total. If you store the tax *amount*,
you do the rounding only once.
I've always store the amount rather than the rate, and for the
same reasons. Recently I've begun to question whether this is
still justified.


Strictly, we are denomalizing when we store the amount of tax,
as it is dependant on the amount of the transaction. As
processor power increases, the number of cases where
denormalization makes sense decreases. What we did in dBase
III on a PC with no hard disk and 128*K* of RAM is not always
appropriate today.
Since the rate may vary with date, category of merchandize, as well
as other exemptions you are not denormalizing until you store all
of the variables in the calculation as well as the result. Whether
you store the rate, and calculate the value, or calculate then
store the value, you still require one field. If you store the
value you can determine the rate.

Storing the tax rate and calcuating on the fly means:
1. Store the rate per row, since countries have specific items
that are tax-ex.
2. Use a query as the source for forms/reports, to include the
calculated field (tax amount).
3. The calculated field must be explicitly typecast to
Currency. (*No* calculated field can be trusted without
typecasting.) 4. Currency cannot be Null, so the calcuation
must involve Nz(). 5. The row must be rounded to prevent
apparent addition errors if the client wants to see the
tax-inc amount on each row.

Result:
TaxAmount: Round(CCur(Nz([Quantity] * [UnitPrice] *
[TaxRate],0)), 2)

The question is whether processor speed now justifies
performing such a calcuation at every row of the invoice in
preference to storing the denomalized tax amount. Guess we
should run some timing trials to find out. Variables would
include processor type/speed, local verses networked, JET
verses MSDE.

I don't feel its worth the effort to save essentially 0 bytes of
disk space, since you need to store the rate per row in order to
make the calculation or the result of the calculation. .
Nov 12 '05 #6

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

Similar topics

6
1600
by: Marek Ropski | last post by:
If I have a form bound to a 'local table query' eg a table of contacts with first and last names, plus a calculated field for the full name: SELECT ConID, ConFirst, ConLast, ( & ) AS ConFull FROM tblContact I place all 4 fields as textboxes on the form and after changing 'Smitt' to 'Smith' if I move my cursor to txtFirstName, I find that the full name changes automatically to reflect the new surname although I have not saved the...
2
4830
by: Alpha | last post by:
Hi, I have a window based program. One of the form has several textboxes and a datagrid. The textboxes are bind to the same dataset table as the datagrid and the text changes to reflect different row selected in the datagrid. I want to save the changes that user make in the textboxes when they select a different row in the datagrid. I tried capturing the textbox.text at datagrid's CurrentCellChanged event but by then the textbox.text...
0
3019
by: colleen1980 | last post by:
Hi: There are two textboxs in my main form. One is bound and another is unbound. There is no entry in the unbound textbox as values come into automatically after entering some information in the subform. My question is how to i pass values from unbound textbox to bound textbox every time when the value change in unbound textbox i need to change the value in the bound textbox. When the form load there is already value in the bound textbox...
4
26712
by: Tomasz Jastrzebski | last post by:
Hello Everyone, I have a GridView control bound to a plain DataTable object. AutoGenerateEditButton is set to true, Edit button gets displayed, and RowEditing event fires as expected.
5
2603
by: njb35 | last post by:
Hi all I'm beginning my foray from VBA into VB 2005 Express, and enjoying some of the efficiencies it provides! I'm stuck with some dataset handling however that I _think_ can be automated but I can probably code what I want to do the hard way. I've searching around online but can't find an answer to this specific question. Here's the situation: I have a dataset table with 3 fields: one indexed as a primary key and the other two...
1
2469
by: cclayton000 | last post by:
Does anyone have a basic example of a script that can automatically fill fields in a subform? Here is the scenario: I have a main form for a Sample Lot and I have added some side-fields (not bound to any table) that asks basic information: Number of Samples (x), Quantity, Unit of Measure, Location, Tray...I would then like a button that triggers a script to automatically create the Sample Details (subform) that is autonumbered and then...
4
1634
nev
by: nev | last post by:
i have a bound textbox. i am in record 2 and textbox displays 'hello'. now i added code to automatically save a new word entered in textbox. for example, while in record 2 which textbox displays 'hello', i modify it into 'helicopter'. when i process the save, the word will become 'hello' again (but i'm still in record 2). and i know it saved because when i do... bindingsource.movenext bindingsource.moveprevious my textbox displays...
4
2646
by: Terry | last post by:
I am trying to figure out if there is a way to get a regular asp.net TextBox to fill the screen, both height and width. When I drop a TextBox onto a blank asp.net page and set the height="100%", width="100", and the TextMode="MultiLine", the TextBox will fill the width of the page, and will adjust the width dynamically as the page changes size, but the height of the textbox is not full screen as I would like. It remains at 2 lines high....
0
2516
by: Mike | last post by:
So here's the situation (.NET 2.0 btw): I have a form, and on this form is a textbox among many other databound controls. The textbox is bound to a field in a data table via the Text property. In this table there are multiple columns that cannot be NULL, which, are bound to other controls (but they're not really important at this time). I create a new row via the currency manager like so: _currencyManager.AddNew() _currentRow =...
0
9605
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10651
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10393
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
6893
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5556
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5697
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4342
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3871
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3020
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.