Hey guys!
I figured it might be easier to have my various questions in seperate posts, to avoid confusion.
My next problem is that with two of my tables (Hours Worked and Occupations) when i want to save the records, it places the correct values (taken from text boxes on the form) and sets the recordset to thos values, but then for some strange reason, it uses the the data from the first record in the table to update the record.
i.e. Record 1 = employee id: 001 name: "Donald"
Record 2 = employee id: 002 name: "Sammy"
new name for record 2 = "Sam"
thus Record 2 should = employee id: 002 name:Sam
but something in my code causes it to become
employee id:002 name
onald
here is the code for the hours worked save button
The query that updates the hours worked is as follows:
And then i'm also getting an error: Column 'Employee_ID' is constrained to be unique. Value '12' is already present, but i'm not (or at least i'm not intending to change the employee_id. i just want to change the number of hours worked where the employee_id is the same as the employee_id in my current row)
These errors have stumped me. Maybe its the lack of sleep or possibly my lack of knowledge, but i'd really, really appreciate some help since i have to get this program finished by next week
Thanks for taking the time to read my post
Laura
I figured it might be easier to have my various questions in seperate posts, to avoid confusion.
My next problem is that with two of my tables (Hours Worked and Occupations) when i want to save the records, it places the correct values (taken from text boxes on the form) and sets the recordset to thos values, but then for some strange reason, it uses the the data from the first record in the table to update the record.
i.e. Record 1 = employee id: 001 name: "Donald"
Record 2 = employee id: 002 name: "Sammy"
new name for record 2 = "Sam"
thus Record 2 should = employee id: 002 name:Sam
but something in my code causes it to become
employee id:002 name

here is the code for the hours worked save button
Code:
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] CmdSave_Click([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] CmdSave.Click[/SIZE]
[SIZE=2][COLOR=#008000]' button to save record[/COLOR][/SIZE]
[SIZE=2][COLOR=#008000]' fill table adapter with records[/COLOR][/SIZE]
[SIZE=2]Employee_Hours_Worked_TableTableAdapter.Fill(PayrollDatabaseDataSet.Employee_Hours_Worked_Table)[/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][COLOR=#008000]' variable to store records[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] row [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] payrollDatabaseDataSet.Employee_Hours_Worked_TableRow[/SIZE]
[SIZE=2]row = PayrollDatabaseDataSet.Employee_Hours_Worked_Table.Rows(current_row)[/SIZE]
[SIZE=2][COLOR=#008000]' user must confirm update[/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]' fill variables[/COLOR][/SIZE]
[SIZE=2]row.Hours_Worked_Normal = Hours_Worked_NormalTextBox.Text[/SIZE]
[SIZE=2]row.Hours_Worked_Overtime_1 = Hours_Worked_Overtime_1TextBox.Text[/SIZE]
[SIZE=2]row.Hours_Worked_Overtime_1andhalf = Hours_Worked_Overtime_1andhalfTextBox.Text[/SIZE]
[SIZE=2]row.Hours_worked_overtime_2 = Hours_worked_overtime_2TextBox.Text[/SIZE]
[SIZE=2][COLOR=#008000]' update record[/COLOR][/SIZE]
[SIZE=2]Employee_Hours_Worked_TableTableAdapter.UpdateQueryHoursWorked(row.Hours_Worked_Normal, row.Hours_Worked_Overtime_1, row.Hours_Worked_Overtime_1andhalf, row.Hours_worked_overtime_2, row.Employee_ID)[/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]' show first record[/COLOR][/SIZE]
[SIZE=2]current_row = 0[/SIZE]
[SIZE=2]ShowCurrentRecord()[/SIZE]
The query that updates the hours worked is as follows:
Code:
UPDATE Employee_Hours_Worked_Table
SET Hours_Worked_Normal = ?, Hours_Worked_Overtime_1 = ?, Hours_Worked_Overtime_1andhalf = ?, Hours_worked_overtime_2 = ?
WHERE (Employee_ID = ?)
And then i'm also getting an error: Column 'Employee_ID' is constrained to be unique. Value '12' is already present, but i'm not (or at least i'm not intending to change the employee_id. i just want to change the number of hours worked where the employee_id is the same as the employee_id in my current row)
These errors have stumped me. Maybe its the lack of sleep or possibly my lack of knowledge, but i'd really, really appreciate some help since i have to get this program finished by next week

Thanks for taking the time to read my post
Laura