473,403 Members | 2,270 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,403 software developers and data experts.

how can i update a field in a table from a form ?

115 100+
Hi i have this table:
item (article# , price , PRICE_AFTER_DISCOUNT)
i wanna update PRICE_AFTER_DISCOUNT how can i do it? if it's at the first place = null
Aug 5 '10 #1
6 1134
jimatqsi
1,271 Expert 1GB
Well, you don't give us a lot to go on, but let's make some assumptions. I assume the article number (let's not use the pound sign as part of an identifier) is all you need to identify the item in the table. Also assume you want the price after discount updated after changing the price value.

I assume also that the 3 data items all appear on the form. Let's say they are in text boxes and the text box names are txtArticle, txtPrice, txtPriceAfterDiscount.

One further assumption we'll make is that the discount is 10% of the regular price.

Here's how you make your update. In the AfterUpdate event of the txtPrice ojbect, put this code.
Expand|Select|Wrap|Line Numbers
  1. me!txtPriceAfterDiscount=round(me!txtPrice - (me!txtPrice*.10),2)
Oh dear, I see I made another assumption, that being you want 2 decimal precision, and we don't even need the assumption about the article number being the primary key. Anyway, I think you have enough to start with.

Let us know how far this takes you.

Jim
Aug 5 '10 #2
hannoudw
115 100+
thanks Jim
i have another question
i'm now doing the invoice customer form
and i had those text box :
txtarticle, txtPrice, txtAfterDiscPrice, txtCashMoney
i want to write this code
Expand|Select|Wrap|Line Numbers
  1. If (txtAfterDiscPrice is null) then txtCashMoney=txtPrice ;
  2. else 
  3. txtCashMoney=txtAfterDiscPrice;
on the default value of the txtCashMoney.

so i wrote this on the default value of the txtCashMoney:
Expand|Select|Wrap|Line Numbers
  1. = iif(isnull(txtAfterDiscPrice ) ,= [txtPrice] ,= [txtAfterDiscPrice ] 
but it's not working does anyone know why ?
Aug 5 '10 #3
jimatqsi
1,271 Expert 1GB
Is txtCashMoney bound to a data item? I'm not sure the object default value is the place to put that. Maybe you could put that code in the OnCurrent event of the form; then it would get executed for the current detail line whenever you change from one row to another.

But I'm not sure you want to do that either. A lot depends on the business rules and processes surrounding this form. Is the form the source for getting pricing into the inventory database? If yes, then the AfterUpdate event of the txtPrice object is the perfect place to update the discounted price. The discounted prices get updated one at a time just as you enter/edit the price.

However, if the prices are being imported from elsewhere, maybe it would be better to have a query that updates all the discounted prices at once, based on the price already stored in each item.

Jim
Aug 6 '10 #4
NeoPa
32,556 Expert Mod 16PB
Forget that Jim. This question has subsequently been asked and answered elsewhere (iif statement in a default value not working).

Hannoudw,

Please do not post multiple questions in the same thread. It is against the rules because it causes confusion and wastes a lot of the time of those members who are making efforts to help you.

It might show good manners if you checked out the rules before continuing to use the services.
Aug 6 '10 #5
hannoudw
115 100+
@NeoPa
sorry about that i didn't knew it :(
Aug 6 '10 #6
NeoPa
32,556 Expert Mod 16PB
And now you do but have posted twice more since then.

These have been deleted. You will get notification of that so you can repost them properly if you need to.

I am now locking this thread.
Aug 6 '10 #7

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

Similar topics

0
by: EKL | last post by:
Hi, I'm making a sort of Customer and Orders database in MS Access 2003. My problem is that I wish to update the table "tblTransaction" based on changes made in the table "tblOrderDetails"....
1
by: Kelly Olsen | last post by:
I have created an automatic update field in my Vendor_Table that automatically updates the date in that field to respond to any changes made to the record. However, I would like to display this...
1
by: Sharon | last post by:
Hello All, Is it possible to update Sql Table through DataGrid. I have a DataGrid which is being populated through a stored procedure, all i wanted to do is to update one field...
1
by: Seemaraj | last post by:
I have doubt in VB.Net on how to update the records in table. I m using MS Access database. I have a table named len_graph with 9 fields like...
5
by: sensreview | last post by:
Hello, I need help in selecting a value from combo list thru one lookup table and update different table on MS access form. For eg; I have a lookup table of usernames, I need to use this...
3
by: feeman | last post by:
What I am looking at doing is I have a couple of forms, when I enter the number of products been despatched on the order form, it then creates a record in the transaction table and also the product...
1
by: vaiism | last post by:
I have attempted using both Updata and Append Queries to solve this problem, and I can't seem to get it to work. I have three forms that each have an ID#, and a subform with related scores to...
0
by: grasshopper2 | last post by:
I am trying to update a table on a sql 2000 or 2005 box ( am not sure what version its running how do I check?) I am so green I feel like kermit the frog! computer is running windows 2000,...
3
by: Alexio | last post by:
I need to enter a date into a text field when form is loaded. However I need this date to be static when the form is opened at a later date. I have the text box set to readonly. Will this be...
7
by: troy_lee | last post by:
I have an unbound form. I have an Add New procedure that saves a new record to the database. What is the best way to update an existing record? In other words, clicking my "Submit record" button...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.