hi friend, i want that my program should work like this, after inputs of total amount and expenses
it automatically give the Total Expense and than TOTAL AMOUNT - TOTAL EXPENSE it give me the Remaining Amount.
the total Expense and Remaining Amount should show in a text boxes. as i designed in project.

Expense 1+Expense2+Expense3......Expense8 = Total Expense
Amount - Total Expense = Remain Amount

iam attaching the project for your ease .Thank you.

Edited 5 Years Ago by satti: n/a

there is another way if i sum up these calculation in access summing quarries and than it automatically shown by text boxes ..is that possible?

and don't upload entire project just post your code which it relevant with your question

Edited 5 Years Ago by Jx_Man: n/a

its so strange that i have uploaded my project to show you what iam doing and you are still asking to show you my effort???... what exactly i want to know is iam making the sale form, it allows to enter the Amount and expenses which is ok ,now i want that it show the Total expense and then it subtract the total expense from actual amount..
This is why i have uploaded the project to let you know what i want..
just have a look at interface there are 2 text boxes below data grid .
1. is Total Expense ,and second is Remaining Amount .i want this to show data here.

@makman99 ...dear have a look at interface iwant the 2 text fields of Total expense and Remaining Amount to show data .they are below the datagrid.

Write down the below code in the text field's (txtexpense3) lostfocus or keydown event. In your code txtexpense3 is written as txtexpemse3

Text2.Text = Val(txtCommision.Text) + Val(txtRent.Text) + Val(txtLabour.Text) + Val(txtReturnExpense.Text) + Val(txtExpense2.Text) + Val(txtStoreExpense.Text) + Val(txtPhoneExpense.Text) + Val(txtExpense3.Text)
Text1.Text = Val(txtNetPrice) - Val(Text2.Text)

Edited 5 Years Ago by P.manidas: n/a

its so strange that i have uploaded my project to show you what iam doing and you are still asking to show you my effort???... what exactly i want to know is iam making the sale form, it allows to enter the Amount and expenses which is ok ,now i want that it show the Total expense and then it subtract the total expense from actual amount..
This is why i have uploaded the project to let you know what i want..
just have a look at interface there are 2 text boxes below data grid .
1. is Total Expense ,and second is Remaining Amount .i want this to show data here.

its not about your project but your Effort on your Question..and it not showing on your project...
this an example, modified as u needed..

TextboxTotalExpense.text = val(textboxExpense1.text) + val(textboxExpense2.text) + .... + val(textboxExpense8.text)
TextboxRemainAmount.Text = Val(TextBoxAmount.Text) - val(TextboxTotalExpense.text)

place it on any event that you want.

its so strange that i have uploaded my project to show you what iam doing and you are still asking to show you my effort???

the solution to the problem is simple arithmetic.

@satti

so far as uploaded the entire project file is concerned, i am here to share my knowledge because i love to do so but i do not open each and every file / attachment that i come across in net.

Edited 5 Years Ago by debasisdas: n/a

@ P.ManiDAS & JX Man thank you both of you , am gonna use the code the way you told, will tell you if faced any problem .thanks

@ P.Manidas ihave pasted the code as u told but the text 1 and text2 boxes are showing no change... they are not giving any calculated answer,and ihave corrected Expemse to Expense

Option Explicit

' couple'o global vars for size trackin'
Dim MinHeight As Long
Dim MinWidth As Long

Private Sub cmdAddEntry_Click()
' add a new entry to our table.
    With DataEnvironment1.rsDataTable
        .AddNew
        !CodeNo = txtCodeNo
        !DealerName = txtDealerName
        !TruckNumber = txtTruckNumber
        !Quantity = txtQuantity
        !NetPrice = txtNetPrice
        !Commision = txtCommision
        !Rent = txtRent
        !Labour = txtLabour
        !ReturnExpense = txtReturnExpense
        !Expense2 = txtExpense2
        !StoreExpense = txtStoreExpense
        !PhoneExpense = txtPhoneExpense
        !Expemse3 = txtExpense3
        
        .Update
    End With
    
    ' requery the db and re-bind the data source to the data grid
    DataEnvironment1.rsDataTable.Requery
    Set DataGrid1.DataSource = DataEnvironment1
    
    ' clear the text fields once the new record is added
    txtCodeNo.Text = ""
    txtDealerName.Text = ""
    txtTruckNumber.Text = ""
    txtQuantity.Text = ""
    txtNetPrice.Text = ""
    txtCommision.Text = ""
    txtRent.Text = ""
    txtLabour.Text = ""
    txtReturnExpense.Text = ""
    txtExpense2.Text = ""
    txtStoreExpense.Text = ""
    txtPhoneExpense.Text = ""
    txtExpense3.Text = ""
   
    ' set the focus back to the CodeNo textbox
    txtCodeNo.SetFocus

End Sub

Private Sub cmdRemoveEntry_Click()
    ' remove the currently selected item from the database
    DataEnvironment1.rsDataTable.Delete adAffectCurrent

End Sub

Private Sub DataGrid1_Click()
    cmdRemoveEntry.Enabled = True
End Sub

Sub EnableChoice()
    ' disable to remove button
    ' check to see if every text field has contents.  If they all have
    ' contents (ie, they're not empty) enable the "Add Entry" button.
    
    If txtCodeNo.Text <> "" _
    And txtDealerName.Text <> "" _
    And txtTruckNumber.Text <> "" _
    And txtQuantity.Text <> "" _
    And txtNetPrice.Text <> "" _
    And txtCommision.Text <> "" _
    And txtRent.Text <> "" _
    And txtLabour.Text <> "" _
    And txtReturnExpense.Text <> "" _
    And txtExpense2.Text <> "" _
    And txtStoreExpense.Text <> "" _
    And txtPhoneExpense.Text <> "" _
    And txtExpense3.Text <> "" Then
        cmdAddEntry.Enabled = True
    Else
        cmdAddEntry.Enabled = False
    End If
    cmdRemoveEntry.Enabled = False

End Sub

Private Sub Text1_Change()
Text1.Text = Val(txtNetPrice) - Val(Text2.Text)
End Sub

Private Sub Text2_Change()

Text2.Text = Val(txtCommision.Text) + Val(txtRent.Text) + Val(txtLabour.Text) + Val(txtReturnExpense.Text) + Val(txtExpense2.Text) + Val(txtStoreExpense.Text) + Val(txtPhoneExpense.Text) + Val(txtExpense3.Text)
End Sub

Private Sub txtCodeNo_Change()
    EnableChoice
End Sub

Private Sub txtCommision_Change()
    EnableChoice
End Sub

Private Sub txtDealerName_Change()
    EnableChoice
End Sub

Private Sub txtExpense3_Change()
    EnableChoice
End Sub

Private Sub txtExpense2_Change()
    EnableChoice
End Sub

Private Sub txtLabour_Change()
    EnableChoice
End Sub

Private Sub txtNetPrice_Change()
    EnableChoice
End Sub

Private Sub txtPhoneExpense_Change()
    EnableChoice
End Sub

Private Sub txtQuantity_Change()
    EnableChoice
End Sub

Private Sub txtRent_Change()
    EnableChoice
End Sub

Private Sub txtReturnExpense_Change()
    EnableChoice
End Sub

Private Sub txtStoreExpense_Change()
    EnableChoice
End Sub

Private Sub txtTotal_Change()
    EnableChoice
End Sub

Private Sub txtTotalExpense_Change()
    EnableChoice
End Sub

Private Sub txtTruckNumber_Change()
    EnableChoice
End Sub

Edited 5 Years Ago by satti: n/a

Satti, in my earlier reply i have told you to use my code in the lostfocus of keydown event of txtExpense3 textbox but you use in text1 and text2's change event. Not like that. Use these whole code.

after using these code reply again. I am in Online.

Private Sub txtExpense3_LostFocus()
Text2.Text = Val(txtCommision.Text) + Val(txtRent.Text) + Val(txtLabour.Text) + Val(txtReturnExpense.Text) + Val(txtExpense2.Text) + Val(txtStoreExpense.Text) + Val(txtPhoneExpense.Text) + Val(txtExpense3.Text)
Text1.Text = Val(txtNetPrice) - Val(Text2.Text)
End Sub

Edited 5 Years Ago by P.manidas: n/a

actually, put your code in all exepense textboxes key down event (cause user can change them all as they want).

@P.Manidas ok i understood what you said,but the thing is expense3 is itself a text box ro enter data ,but idid and textbox 1 and 2 are giving rite answer but the problem is when i try to add it give me an error ,,that the item cannot be found in the collection corresponding to your request.and error it show the error at !Expense3 = txtExpense3...i have pointed the error

Option Explicit

' couple'o global vars for size trackin'
Dim MinHeight As Long
Dim MinWidth As Long

Private Sub cmdAddEntry_Click()
' add a new entry to our table.
    With DataEnvironment1.rsDataTable
        .AddNew
        !CodeNo = txtCodeNo
        !DealerName = txtDealerName
        !TruckNumber = txtTruckNumber
        !Quantity = txtQuantity
        !NetPrice = txtNetPrice
        !Commision = txtCommision
        !Rent = txtRent
        !Labour = txtLabour
        !ReturnExpense = txtReturnExpense
        !Expense2 = txtExpense2
        !StoreExpense = txtStoreExpense
        !PhoneExpense = txtPhoneExpense
        !Expense3 = txtExpense3...........................................error
        
        .Update
    End With
    
    ' requery the db and re-bind the data source to the data grid
    DataEnvironment1.rsDataTable.Requery
    Set DataGrid1.DataSource = DataEnvironment1
    
    ' clear the text fields once the new record is added
    txtCodeNo.Text = ""
    txtDealerName.Text = ""
    txtTruckNumber.Text = ""
    txtQuantity.Text = ""
    txtNetPrice.Text = ""
    txtCommision.Text = ""
    txtRent.Text = ""
    txtLabour.Text = ""
    txtReturnExpense.Text = ""
    txtExpense2.Text = ""
    txtStoreExpense.Text = ""
    txtPhoneExpense.Text = ""
    txtExpense3.Text = ""
   
    ' set the focus back to the CodeNo textbox
    txtCodeNo.SetFocus

End Sub

Private Sub cmdRemoveEntry_Click()
    ' remove the currently selected item from the database
    DataEnvironment1.rsDataTable.Delete adAffectCurrent

End Sub

Private Sub DataGrid1_Click()
    cmdRemoveEntry.Enabled = True
End Sub

Sub EnableChoice()
    ' disable to remove button
    ' check to see if every text field has contents.  If they all have
    ' contents (ie, they're not empty) enable the "Add Entry" button.
    
    If txtCodeNo.Text <> "" _
    And txtDealerName.Text <> "" _
    And txtTruckNumber.Text <> "" _
    And txtQuantity.Text <> "" _
    And txtNetPrice.Text <> "" _
    And txtCommision.Text <> "" _
    And txtRent.Text <> "" _
    And txtLabour.Text <> "" _
    And txtReturnExpense.Text <> "" _
    And txtExpense2.Text <> "" _
    And txtStoreExpense.Text <> "" _
    And txtPhoneExpense.Text <> "" _
    And txtExpense3.Text <> "" Then
        cmdAddEntry.Enabled = True
    Else
        cmdAddEntry.Enabled = False
    End If
    cmdRemoveEntry.Enabled = False

End Sub


Private Sub Text1_LostFocus()
Text1.Text = Val(txtNetPrice) - Val(Text2.Text)
End Sub

Private Sub Text2_LostFocus()

Text2.Text = Val(txtCommision.Text) + Val(txtRent.Text) + Val(txtLabour.Text) + Val(txtReturnExpense.Text) + Val(txtExpense2.Text) + Val(txtStoreExpense.Text) + Val(txtPhoneExpense.Text) + Val(txtExpense3.Text)
End Sub

Private Sub txtCodeNo_Change()
    EnableChoice
End Sub

Private Sub txtCommision_Change()
    EnableChoice
End Sub

Private Sub txtDealerName_Change()
    EnableChoice
End Sub

Private Sub txtExpense3_Change()
    EnableChoice
End Sub
   
      Private Sub txtExpense3_LostFocus()
   
      Text2.Text = Val(txtCommision.Text) + Val(txtRent.Text) + Val(txtLabour.Text) + Val(txtReturnExpense.Text) + Val(txtExpense2.Text) + Val(txtStoreExpense.Text) + Val(txtPhoneExpense.Text) + Val(txtExpense3.Text)
   
      Text1.Text = Val(txtNetPrice) - Val(Text2.Text)
   
      End Sub

Private Sub txtExpense2_Change()
    EnableChoice
End Sub

Private Sub txtLabour_Change()
    EnableChoice
End Sub

Private Sub txtNetPrice_Change()
    EnableChoice
End Sub

Private Sub txtPhoneExpense_Change()
    EnableChoice
End Sub

Private Sub txtQuantity_Change()
    EnableChoice
End Sub

Private Sub txtRent_Change()
    EnableChoice
End Sub

Private Sub txtReturnExpense_Change()
    EnableChoice
End Sub

Private Sub txtStoreExpense_Change()
    EnableChoice
End Sub

Private Sub txtTotal_Change()
    EnableChoice
End Sub

Private Sub txtTotalExpense_Change()
    EnableChoice
End Sub

Private Sub txtTruckNumber_Change()
    EnableChoice
End Sub

Edited 5 Years Ago by satti: n/a

And i have checked the database all the values are entered except Total Expense and Remaining Amount

item cannot be found in the collection corresponding to your request.and error it show the error at !Expense3 = txtExpense3...i have pointed the error

Double check your spelling. The error is because the field does not exist in the database table. If it does exist, the spelling is incorrect.

ok cleared the error in database but now Expense3 ,Total Expense and Remaining Amount from Text1 and Text2 is not saved in database ...????why

Edited 5 Years Ago by satti: n/a

Thank you so much P.Manidas and AndreRet ,errors are gone a form is calm and running good..thank you again....Bless you people.

This question has already been answered. Start a new discussion instead.