Problems with saving 1st record

Loony064

Registered User.
Local time
Today, 18:44
Joined
Jun 4, 2008
Messages
10
Hey guys

I'm pretty close to finishing this payroll program, but i've run in to yet some more problems and i can't figure out how to fix them.

So, i have various forms representing different tables of my database (Access - the database is connected to my vb application as a data source)

Take for instance the employee table. You can add and delete records from the table as well as make changes to the fields. The add and delete buttons on my form work properly, and if i go to the 2nd record upwards, the save button works, but when i try update the first record, the changes don't stick.

Here is a code snippet. This one is from the Save button for a table called Allowances pay.
Code:
[SIZE=2][COLOR=#008000]' save current record[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]' variables to store records[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] row, datar2 [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] payrollDatabaseDataSet.Allowances_Pay_TableRow[/SIZE]
[SIZE=2]row = PayrollDatabaseDataSet.Allowances_Pay_Table.Rows(current_row)[/SIZE]
[SIZE=2]datar2 = PayrollDatabaseDataSet.Allowances_Pay_Table.Rows(0)[/SIZE]
[SIZE=2][COLOR=#008000]' user must confirm the edit[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] confirm [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE]
[SIZE=2]confirm = MsgBox([/SIZE][SIZE=2][COLOR=#800000]"Are you sure you want to alter this record"[/COLOR][/SIZE][SIZE=2], 1 + 48, [/SIZE][SIZE=2][COLOR=#800000]"Please Confirm"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] confirm = 1 [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]' get new values for variables[/COLOR][/SIZE]
[SIZE=2]row.employee_ID = [/SIZE][SIZE=2][COLOR=#0000ff]CStr[/COLOR][/SIZE][SIZE=2](Employee_IDTextBox.Text)[/SIZE]
[SIZE=2]row.allowances_ID = Allowances_IDTextBox.Text[/SIZE]
[SIZE=2]row.allowances_amount = Allowances_amountTextBox.Text[/SIZE]
[SIZE=2][COLOR=#0000ff]Else[/COLOR][/SIZE][SIZE=2] : MsgBox([/SIZE][SIZE=2][COLOR=#800000]"Action cancelled!"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]' update record[/COLOR][/SIZE]
[SIZE=2]Allowances_Pay_TableTableAdapter.Update(row)[/SIZE]
[SIZE=2]Allowances_Pay_TableTableAdapter.Update(PayrollDatabaseDataSet.Allowances_Pay_Table)[/SIZE]
I put in a breakpoint just before the update section of the code and checked the values for row.employee_id, etc. The values stored in them are all correct, so i presume it must be the way i'm calling the update procedure.
 

Users who are viewing this thread

Back
Top Bottom