Zydeceltico
Registered User.
- Local time
- Today, 08:15
- Joined
- Dec 5, 2017
- Messages
- 843
Hi All -
I have a table tblCoils. Primary key (autonumber) is CoilNumber_PK. Main field is CoilNumber which is indexed, required, and Yes (No Duplicates).
On my main menu I have a button titled "Coils Add/Edit." Clicking that button opens frmCoils which has two buttons of importance: one to "Find Coil" and one to "Add New Coil."
Clicking "Find Coil" opens frmCoilStatus with this code:
When frmCoilStatus opens it goes to the first record in the table which is fine. The form has two enabled buttons one of which is "Add Coil" because I would like to allow the user to enter a new coil from here without returning to the previous form. Clicking the "Add Coil" button does clear all fields in the form and moves to a new record.
The click event for the "Add Coil" button has this code:
The user enters a new coil number in txtCoilNumber and can then click a "Save and Close" button.
The code for the "Save and Close" button is this:
When I enter a new coil number in txtCoilNumber and click the"Save and Close" button I get Runtime Error 3022 saying "The changes you requested......because they would create duplicate values, etc.......Change the data in the field..................or redefine the inex to permit duplicate entries........."
But I am not entering duplicate values and I can from the record selector at the bottom of the form that I am definitely on a new record.
And ..........if I DO NOT enter a coil number and click "Save and Close" I get runtime error 3314 which recognizes that CoilNumber is required and says I must enter a value.
Thoughts?
I have a table tblCoils. Primary key (autonumber) is CoilNumber_PK. Main field is CoilNumber which is indexed, required, and Yes (No Duplicates).
On my main menu I have a button titled "Coils Add/Edit." Clicking that button opens frmCoils which has two buttons of importance: one to "Find Coil" and one to "Add New Coil."
Clicking "Find Coil" opens frmCoilStatus with this code:
Code:
Private Sub cmdOpenCoilDetails_Click()
DoCmd.Close 'closes frmCoils
DoCmd.OpenForm "frmCoilStatus"
Forms![frmCoilStatus].[cmdUndoCoilStatus].Enabled = False
Forms![frmCoilStatus].[cmdSaveCoilStatus].Enabled = False
End Sub
When frmCoilStatus opens it goes to the first record in the table which is fine. The form has two enabled buttons one of which is "Add Coil" because I would like to allow the user to enter a new coil from here without returning to the previous form. Clicking the "Add Coil" button does clear all fields in the form and moves to a new record.
The click event for the "Add Coil" button has this code:
Code:
Private Sub cmdAddCoil_Click()
On Error GoTo cmdAddCoil_Click_Err
On Error Resume Next
DoCmd.GoToRecord , "", acNewRec
Forms![frmCoilStatus]![cmdSaveCoilStatus].Enabled = True
Forms![frmCoilStatus]![cmdUndoCoilStatus].Enabled = True
cmdAddCoil_Click_Exit:
Exit Sub
cmdAddCoil_Click_Err:
MsgBox Error$
Resume cmdAddCoil_Click_Exit
End Sub
The user enters a new coil number in txtCoilNumber and can then click a "Save and Close" button.
The code for the "Save and Close" button is this:
Code:
Private Sub cmdSaveCoilStatus_Click()
DoCmd.RunCommand acCmdSaveRecord
DoCmd.Close
End Sub
When I enter a new coil number in txtCoilNumber and click the"Save and Close" button I get Runtime Error 3022 saying "The changes you requested......because they would create duplicate values, etc.......Change the data in the field..................or redefine the inex to permit duplicate entries........."
But I am not entering duplicate values and I can from the record selector at the bottom of the form that I am definitely on a new record.
And ..........if I DO NOT enter a coil number and click "Save and Close" I get runtime error 3314 which recognizes that CoilNumber is required and says I must enter a value.
Thoughts?
Attachments
Last edited: