S
Seren
I have a form that contains several subforms. the application counts
scrapped parts for each area that it goes through so that they can keep track
of where the most problems occur. They also want the percent for each area
so they know how many more than what was ordered needs to be started. There
is a field on the main form called txtQtyStarted that accepts a number.
Because the client wanted to be able to get the percentage from each subform
(area), I went back and added txtQtyStart to each of the subtables and linked
each to the main form using this field as well as the JobID field. The
process requires that the user can later go back and look at all the numbers
entered and determine and enter a "Tech Code" (txtTC on each subform) for
each area. After adding the QtyStart field and linking them, I discovered
that, if a number is entered in the QtyStarted field on the main form, I get
the following, and thus am unable to save the record with the new tech code
in it. It seems like it is trying to create a new record out of it instead
of just updating the one already there. (Actually, I know this because
before I "fixed" it, I could see two records- but each JobNumber needs to be
unique) *However*, if a quantity is not entered, the record will update.
Error Message:
“The changes you requested to the table were not successful because they
would create duplicate values in the index, primary key, or relationship.
Change the data in the field or fields that contain duplicate data, remove
the index, or redefine the index to permit duplicate entries and try again.â€
Unsuccessful Attempt to Fix:
Private Sub txtTC_AfterUpdate()
Screen.ActiveControl = UCase(Screen.ActiveControl)
Dim strSql
strSql = "UPDATE tblbbt SET txtTC = " & Form_subBbt.txtTC & _
" WHERE txtJobNum = " & Form_frmWCYields.txtJobNum
InputBox strSql, strSql, strSql
Form_subBbt.Form.RecordSource = strSql
Form_subBbt.Form.Requery
End Sub
Any help on this would be greatly appreciated!!!
Thank you!
Seren
scrapped parts for each area that it goes through so that they can keep track
of where the most problems occur. They also want the percent for each area
so they know how many more than what was ordered needs to be started. There
is a field on the main form called txtQtyStarted that accepts a number.
Because the client wanted to be able to get the percentage from each subform
(area), I went back and added txtQtyStart to each of the subtables and linked
each to the main form using this field as well as the JobID field. The
process requires that the user can later go back and look at all the numbers
entered and determine and enter a "Tech Code" (txtTC on each subform) for
each area. After adding the QtyStart field and linking them, I discovered
that, if a number is entered in the QtyStarted field on the main form, I get
the following, and thus am unable to save the record with the new tech code
in it. It seems like it is trying to create a new record out of it instead
of just updating the one already there. (Actually, I know this because
before I "fixed" it, I could see two records- but each JobNumber needs to be
unique) *However*, if a quantity is not entered, the record will update.
Error Message:
“The changes you requested to the table were not successful because they
would create duplicate values in the index, primary key, or relationship.
Change the data in the field or fields that contain duplicate data, remove
the index, or redefine the index to permit duplicate entries and try again.â€
Unsuccessful Attempt to Fix:
Private Sub txtTC_AfterUpdate()
Screen.ActiveControl = UCase(Screen.ActiveControl)
Dim strSql
strSql = "UPDATE tblbbt SET txtTC = " & Form_subBbt.txtTC & _
" WHERE txtJobNum = " & Form_frmWCYields.txtJobNum
InputBox strSql, strSql, strSql
Form_subBbt.Form.RecordSource = strSql
Form_subBbt.Form.Requery
End Sub
Any help on this would be greatly appreciated!!!
Thank you!
Seren