

In this section, we will create a form to add salary account for existing employees, calculate their net salaries. Note that the net salary is not calculated yet and salary is linked to a single employee.Ĭon.Execute "INSERT INTO Employee (Eno, Ename,Age,Address, Dob, Phone) VALUES ('" & txtEno & "','" & txtEname & "','" & txtAge & "','" & txtAddress & "','" & txtDob & "', '" & txtPhone & "')"Ĭon.Execute "DELETE * FROM Employee WHERE Eno = " & txtEno & ""Ĭon.Execute "UPDATE Employee SET Eno = '" & txtEno & "', Ename = ' " & txtEname & " ', Age = '" & txtAge & " ', Address = '" & txtAddress & "', Dob ='" & txtDob & "', Phone = '" & txtPhone & "' WHERE Eno = ' " & txtEno & " '" Figure 5 – An Instance of Employee Relation Figure 6 – Instance Of Salary Relation
#Simple payroll program in vb update
Leave the Net field empty in Salary table because we need to calculate it and update it from our VB 6 program. It is good to add at least 5 records in both table. Now you can add some records to both the table. These two properties will make sure that if you delete any record from one table, that will also remove it from the other.

Select ‘Enforce Referential Integrity’ and also select ‘Cascade Update Related Fields’ and ‘Cascade Delete Related Record’. You must click on the relationship link and edit the relationship. Figure 3 -Create a One-To-One Relationship between Employee and Salary Table Figure 4 – Enforce Referential Integrity The next step is to add both employee table and salary table in the relationship window. Therefore, we must have a one-to-one relationship between employee table and the salary table.īefore you create the relationship close the tables, then go to database tools in Ms Access and click Relationships. Each employee can have one salary account. The employee number is the unique in both table. Once you have created tables, then you must create a relationship between these two tables. You table must have fields and corresponding data types. When you switch to Design view in Ms Access, you will asked to name your table, you can call it – Employee and click OK. Our task is to create two tables in the database. Save it to you drive in a folder called ‘AccessDB’.Īt this moment the database is empty and it has nothing. Open Ms Access 2013 and click ‘ Create a blank database’ and type the name of the database as ‘ EmpDB.mdb’. The very first step is to create a database in Microsoft Access and add two tables.
