473,397 Members | 1,974 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,397 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 1088
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.