OK i've been pulling my hair out here and my eyes are bugging out. I need another set of eyes to look this over. I am including code that will allow the EU to enter info for a new record and this info will be appended to a table int he same database. I will include the code from form load to give you an idea of the connection and recoedset as well as the code for the insert button. I have a feeling a line of code is in the wrong spot. Oh yeah, the table gets updated, but with a blank line. The info is pulled from the table tot he form just fine.
Private Sub btnPrev_Click()
rs.MovePrevious
If rs.BOF Then
rs.MoveFirst
End If
FillControls
End Sub
Private Sub Form_Load()
On Error GoTo Error_Handler
For Each ctl In Controls
If TypeOf ctl Is TextBox Then
ctl.BackColor = vbWhite
ctl.SetFocus
ctl.Text = ""
txtEmpName.SetFocus
End If
Next
Set cn = CurrentProject.Connection
rs.ActiveConnection = cn
rs.Open "employees", cn, adOpenDynamic, adLockOptimistic, adCmdTable
FillControls
btnNext.Visible = True
btnPrev.Visible = True
btnNew.Visible = True
btnDelete.Visible = True
btnInsert.Visible = False
Exit Sub
Error_Handler:
MsgBox Err.Description & vbCrLf & "Error NUmber:" & Err.Number
Private Sub btnPrev_Click()
rs.MovePrevious
If rs.BOF Then
rs.MoveFirst
End If
FillControls
End Sub
Private Sub Form_Load()
On Error GoTo Error_Handler
For Each ctl In Controls
If TypeOf ctl Is TextBox Then
ctl.BackColor = vbWhite
ctl.SetFocus
ctl.Text = ""
txtEmpName.SetFocus
End If
Next
Set cn = CurrentProject.Connection
rs.ActiveConnection = cn
rs.Open "employees", cn, adOpenDynamic, adLockOptimistic, adCmdTable
FillControls
btnNext.Visible = True
btnPrev.Visible = True
btnNew.Visible = True
btnDelete.Visible = True
btnInsert.Visible = False
Exit Sub
Error_Handler:
MsgBox Err.Description & vbCrLf & "Error NUmber:" & Err.Number
****here is the fillcontrol sub***
Private Sub FillControls()
txtEmpName.SetFocus
txtEmpName.Text = rs.Fields.Item("Employee Name")
txtDept.SetFocus
txtDept.Text = rs.Fields.Item("Department")
txtPP.SetFocus
txtPP.Text = rs.Fields.Item("Pay Period")
txtSchedHrs.SetFocus
txtSchedHrs.Text = rs.Fields.Item("Hours Scheduled")
txtA.SetFocus
txtA.Text = rs.Fields.Item("A Time")
txtB.SetFocus
txtB.Text = rs.Fields.Item("B Time")
End Sub
Private Sub btnPrev_Click()
rs.MovePrevious
If rs.BOF Then
rs.MoveFirst
End If
FillControls
End Sub
Private Sub Form_Load()
On Error GoTo Error_Handler
For Each ctl In Controls
If TypeOf ctl Is TextBox Then
ctl.BackColor = vbWhite
ctl.SetFocus
ctl.Text = ""
txtEmpName.SetFocus
End If
Next
Set cn = CurrentProject.Connection
rs.ActiveConnection = cn
rs.Open "employees", cn, adOpenDynamic, adLockOptimistic, adCmdTable
FillControls
btnNext.Visible = True
btnPrev.Visible = True
btnNew.Visible = True
btnDelete.Visible = True
btnInsert.Visible = False
Exit Sub
Error_Handler:
MsgBox Err.Description & vbCrLf & "Error NUmber:" & Err.Number
Private Sub btnPrev_Click()
rs.MovePrevious
If rs.BOF Then
rs.MoveFirst
End If
FillControls
End Sub
Private Sub Form_Load()
On Error GoTo Error_Handler
For Each ctl In Controls
If TypeOf ctl Is TextBox Then
ctl.BackColor = vbWhite
ctl.SetFocus
ctl.Text = ""
txtEmpName.SetFocus
End If
Next
Set cn = CurrentProject.Connection
rs.ActiveConnection = cn
rs.Open "employees", cn, adOpenDynamic, adLockOptimistic, adCmdTable
FillControls
btnNext.Visible = True
btnPrev.Visible = True
btnNew.Visible = True
btnDelete.Visible = True
btnInsert.Visible = False
Exit Sub
Error_Handler:
MsgBox Err.Description & vbCrLf & "Error NUmber:" & Err.Number
****here is the fillcontrol sub***
Private Sub FillControls()
txtEmpName.SetFocus
txtEmpName.Text = rs.Fields.Item("Employee Name")
txtDept.SetFocus
txtDept.Text = rs.Fields.Item("Department")
txtPP.SetFocus
txtPP.Text = rs.Fields.Item("Pay Period")
txtSchedHrs.SetFocus
txtSchedHrs.Text = rs.Fields.Item("Hours Scheduled")
txtA.SetFocus
txtA.Text = rs.Fields.Item("A Time")
txtB.SetFocus
txtB.Text = rs.Fields.Item("B Time")
End Sub