473,320 Members | 1,846 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,320 software developers and data experts.

value on the base of 2 textboxes

Hi,

I have sale form, which has 2 subforms(saleDetail and serviceDetail),
I have 2 text boxes, one is grandtotal of saledetail and other is grand
total of servicedetail and called txtSaleDetail and txtServiceDetail. I
have another textbox which show total of both text boxes and called
txtbothTotal. If one of txtServiceDetail or txtSaleDetail has no value
in it then it does not show any thing in txtbothTotal, Can any one help
how to do that. I cant set default value of txtSaleDetail or
txtServiceDetail to zero bcz both text boxes are bound to expression.
plzz help me

Nov 13 '05 #1
3 1270

khan wrote:
Hi,

I have sale form, which has 2 subforms(saleDetail and serviceDetail),
I have 2 text boxes, one is grandtotal of saledetail and other is grand
total of servicedetail and called txtSaleDetail and txtServiceDetail. I
have another textbox which show total of both text boxes and called
txtbothTotal. If one of txtServiceDetail or txtSaleDetail has no value
in it then it does not show any thing in txtbothTotal, Can any one help
how to do that. I cant set default value of txtSaleDetail or
txtServiceDetail to zero bcz both text boxes are bound to expression.
plzz help me


You probably have a NULL value in one of them. You need to set the
value in txtbothTotal = IIf(IsNull(txtsaleDetail.Text), 0,
CInt(txtsaleDetail.Text)) + IIf(IsNull(txtserviceDetail.Text), 0,
CInt(txtserviceDetail.Text))

You might prefer to do this in code (Form_Current would be a candidate
event, or possibly the _Changed events of the txt[salw][service]Detail
text boxes.

HTH

Edward

Nov 13 '05 #2
its not working. here what i did. I put this code first behind the
change event of both textboxes, txtsaledetail and txtservisedetail at
the same time, it did nothing. when i put is behind form_current it
gave me an error "you cannot assing value to this object", Plz help me
man. it was looking so simple but it is too complex now. plz plz help

Nov 13 '05 #3

khan wrote:
its not working. here what i did. I put this code first behind the
change event of both textboxes, txtsaledetail and txtservisedetail at
the same time, it did nothing. when i put is behind form_current it
gave me an error "you cannot assing value to this object", Plz help me
man. it was looking so simple but it is too complex now. plz plz help


Ok, what I gave you before was "air code", and I can't make it work
either. However, I've tested this and it works. I don't have any
doubt at all that someone out there (David Fenton, Steve Jorgensen)
could find a more elegant solution, but since you're not paying me
{;-o>

Option Compare Database
Option Explicit

Private Sub txtSaleDetail_AfterUpdate()
txtBothTotal = 0
If Not (IsNull(txtSaleDetail)) Then
txtBothTotal = txtBothTotal + txtSaleDetail
End If
If Not (IsNull(txtServiceDetail)) Then
txtBothTotal = txtBothTotal + txtServiceDetail
End If

End Sub
Private Sub txtServiceDetail_AfterUpdate()
txtBothTotal = 0
If Not (IsNull(txtSaleDetail)) Then
txtBothTotal = txtBothTotal + txtSaleDetail
End If
If Not (IsNull(txtServiceDetail)) Then
txtBothTotal = txtBothTotal + txtServiceDetail
End If

End Sub

Bear in mind that when you set up a code-behind event, in order to be
sure that it binds correctly you need to locate the control on the
form, right-click the Properties, click the "Event" tab, locate the
event you want (in this case "AfterUpdate", click on the ellipsis
button to the right [...] and select "Code Builder".

Hope this helps

Edward

Nov 13 '05 #4

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

Similar topics

1
by: Robert Scheer | last post by:
Hi. I have a form with some textboxes in it. When a user clicks a button, I need to verify if only one of the textboxes if filled and if so, I need to replicate the value of this textbox to all...
1
by: Luis Esteban Valencia | last post by:
Hello. I have a datagird with textboxes on a column item template, I also have 2 other columns that are hidden and I want to retrieve his value. But I havent found how to do it. Thanks very much...
1
by: sck10 | last post by:
Hello, I am trying to change a value when a user goes into edit mode on a DetailsView control. I am trying to use the following, but can not figure out how to get to the bound field...
13
by: dbuchanan | last post by:
Hello, Here is the error message; ---------------------------- Exception Message: ForeignKeyConstraint Lkp_tbl040Cmpt_lkp302SensorType requires the child key values (5) to exist in the...
0
by: rn5a | last post by:
A user control file named Address.ascx has 4 TextBoxes. The logic of this user control is encapsulated in a code-behind file named Address.ascx.vb. The code-behind also defines an Event named...
2
by: technocraze | last post by:
Hi community experts, I am encountering a problem to display the corresponding values of the combo box into the textboxes. I have chose option 1 & 3 for this implementation but neither is working....
7
by: kenny.deneef | last post by:
Hey all We are working on a project and have alot of forms with textboxes on. Now we want to put some input validation keypress events on those textboxes. We got a parent class where we putted...
4
by: John Kotuby | last post by:
Hi all, I have a simple user-form which accepts contact and profile information for the user to edit and save. All the textboxes are working fine and displaying the expected data, both when the...
4
by: akshay01 | last post by:
Hi All, I am using the following code in which i am creating some textboxes and and as the for loop continues the name of the textboxes will also be unique for all the textboxes. now i want to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.