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

what would be the best solution for this code

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdAdd_Click()
  2. Dim NetPay As Double
  3.    If cmdAdd.Caption = "Add" Then
  4.       Adodc1.Recordset.AddNew
  5.       cmdAdd.Caption = "Save"
  6.       cmdUpdate.Enabled = False
  7.       cmdDel.Enabled = False
  8.   Else
  9.       Text9 = Val(txtSSS.Text) + Val(txtTAX.Text) + Val(txtPhilHealth.Text) + Val(txtPagibig.Text) + Val(txtCanteen.Text) + Val(txtOthers.Text)
  10.       TotalDeduction = Format(txtTotalDeduction, "00.00")
  11.       Adodc1.Recordset.Fields("TotalDeduction") = TotalDeduction
  12.       Adodc1.Recordset.Update
  13.       cmdAdd.Caption = "Add"
  14.       cmdUpdate.Enabled = True
  15.       cmdDel.Enabled = True
  16.    End If
  17. End Sub
  18.  
  19. Private Sub cmdDel_Click()
  20.     Adodc1.Recordset.Delete
  21.     Adodc1.Recordset.Requery
  22. End Sub
  23.  
  24. Private Sub cmdUpdate_Click()
  25.     Text10 = Val(txtGrossPay.Text) - Val(txttd.Text)
  26.     Adodc1.Recordset.Update
  27.  
  28. End Sub
  29.  
  30. Private Sub cmdTotalDeduction_Click()
  31. 'to add the value in text 3, text 4, text 5, text 6, text 7, text 8
  32. txtTotalDeduction = Val(txtSSS.Text) + Val(txtTAX.Text) + Val(txtPhilHealth.Text) + Val(txtPagibig.Text) + Val(txtCanteen.Text) + Val(txtOthers.Text)
  33. 'display the amount in text 9
  34. Text9 = Format(txtTotalDeduction, "00.00")
  35.  
  36. End Sub
  37.  
  38. Private Sub cmdNetPay_Click()
  39. 'to minus the value in tex box 2 by text box 9
  40. txtNetPay = Val(txtGrossPay.Text) - Val(txtTotalDeduction.Text)
  41. 'display the amount in text box 10
  42. Text10 = Format(txtNetPay, "00.00")
  43. End Sub
Attached Images
File Type: jpg vb.jpg (48.9 KB, 131 views)
Sep 23 '14 #1
2 1085
Rabbit
12,516 Expert Mod 8TB
Please use code tags when posting code or formatted data.

The error message is pretty clear. You added a new record but didn't populate the primary key.
Sep 23 '14 #2
twinnyfo
3,653 Expert Mod 2GB
chel1414,

Is your Primary Key set up as an AutoNumber? This would fix the problem immediately.
Sep 25 '14 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: python | last post by:
In a file there can be several dictionaries like this {Key11: Value11 Key12: Value12 Key13: Value13, .... .... Key1n:Value1n} {Key21: Value21 Key22: Value22 Key23: Value23,
0
by: David Boaz | last post by:
Hello all, I have an middleware that has to be accessed from two different applications, win-form and asp-form. the middleware uses a file to store and retrieve information. I want to economize...
1
by: Husam | last post by:
Hi EveryBody: Is there any one know how can I use the following code to make windows application project that can start and stop the windows32 service manually?and tell me what the languege this...
8
by: Polaris | last post by:
Hi Experts: The program creates Panels and inicilize them. When I run the code below, the program crashes (at the line commented below). Any help is appriciated. Thanks in Advance! Polaris ...
1
by: hantuitm | last post by:
i need help to find errors in this program and improve its interface. #include <iostream> #include <string> int main() { string InputNumber; string words1,words2,words3,valCheck;
12
by: JC | last post by:
Hi... Anybody knows what problem has this code? I think, in the Garbage Collector? You know the Solution? The program in the test's case, whit 350 contacts, run OK before number 86. The error...
2
by: GaryDean | last post by:
I have inherrited an undocumented asp.net 1.1 application that contains a subproject with about 85 .vb modules that look like they are generated from some kind of data layering tool such as...
1
by: rave3085 | last post by:
Actually this is a part of the code that keeps me wondering why? Dim rsExp As New ADODB.Recordset Dim rsDB As New ADODB.Connection Set rsExp = New ADODB.Recordset ...
12
by: Gustaf | last post by:
I've been working on a membership form for a while, and find it very tedious to get an acceptable level of form validation. A web search for solutions revealed some home-brewed solutions, such as...
0
by: Jason7899 | last post by:
hi, i have a next star lx device for file server that simple sucks. the speed that i have is simple slow in LAN 100MB i only can send files about 4mb/sec or 5mb at maximum, so i think in a...
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...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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.