C
Craig M. Bobchin
Hi all,
I've run into a bit of a problem that I need your help to figure out.
I have a form/subform that I've built for entering timesheet data
(controlsource for the form is a table tblTimeTracker).
On the main form I have an unbound combobox that displays the data from
two key fields for this table (resourceID and weekending date). I'm
using this combo box as a search/selection to allow the users to select
a timesheet to edit.
Once a timesheet is picked, I feed each of these column values to
another set of combo boxes and pull up the record. So far so good.
The problem comes when I try to edit the subform data. I click on a
field in the subform and I get a message box saying that The changes you
requested were not successful because they would create duplicate
valules (you know the rest).
Below is the code from the combobox's AfterUpdate Event: (Beware of
Wrapping)
Private Sub cboSelect_AfterUpdate()
'Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[ResourceID] = " & str(Nz(Me![cboSelect], 0)) & " AND
[WeekID] = " & Me.cboSelect.Column(1)
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
Me.cboResourceID.Enabled = True
Me.cboResourceID.Value = str(Nz(Me![cboSelect], 0))
Me.cboWeekID.Enabled = True
Me.cboWeekID.Value = Me.cboSelect.Column(1)
Me.tblTimeTrackData_Subform.Requery
End Sub
What am I doing wrong in the code and how can I fix it?
Thanks
Craig
I've run into a bit of a problem that I need your help to figure out.
I have a form/subform that I've built for entering timesheet data
(controlsource for the form is a table tblTimeTracker).
On the main form I have an unbound combobox that displays the data from
two key fields for this table (resourceID and weekending date). I'm
using this combo box as a search/selection to allow the users to select
a timesheet to edit.
Once a timesheet is picked, I feed each of these column values to
another set of combo boxes and pull up the record. So far so good.
The problem comes when I try to edit the subform data. I click on a
field in the subform and I get a message box saying that The changes you
requested were not successful because they would create duplicate
valules (you know the rest).
Below is the code from the combobox's AfterUpdate Event: (Beware of
Wrapping)
Private Sub cboSelect_AfterUpdate()
'Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[ResourceID] = " & str(Nz(Me![cboSelect], 0)) & " AND
[WeekID] = " & Me.cboSelect.Column(1)
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
Me.cboResourceID.Enabled = True
Me.cboResourceID.Value = str(Nz(Me![cboSelect], 0))
Me.cboWeekID.Enabled = True
Me.cboWeekID.Value = Me.cboSelect.Column(1)
Me.tblTimeTrackData_Subform.Requery
End Sub
What am I doing wrong in the code and how can I fix it?
Thanks
Craig