bcooler
Programmer
- Jun 13, 2009
- 132
Hello all-
I am having a weird problem and have done a lot of Googling before posting, so here goes:
I have a form that I want to use as both new record entry and existing record review. On entering the form, the default setup is to look at the existing records. When the operator presses the "New Record" button, the event gives a combobox the correct rowsource, controlsource, and sets the DataEntry to True.
The operator can then pick a new part from the combobox. Once the choice is made, I have an error handling code that says:
which calls a module that I often use:
Now, this works well, but I am having a small problem. After the error handling is complete, I have to press "ESC" in the combobox before I can go back to looking at existing records. Otherwise, I get a error 3058.
I understand that this means the record needs a primary key, but I thought the error handling code removed any entry? Why do I have to manually press "ESC" to stop this error? How do I get around this?
Thanks for the help!
I am having a weird problem and have done a lot of Googling before posting, so here goes:
I have a form that I want to use as both new record entry and existing record review. On entering the form, the default setup is to look at the existing records. When the operator presses the "New Record" button, the event gives a combobox the correct rowsource, controlsource, and sets the DataEntry to True.
The operator can then pick a new part from the combobox. Once the choice is made, I have an error handling code that says:
Code:
Private Sub cboPartNo_BeforeUpdate(Cancel As Integer)
If Me.cboPartNo.ControlSource = "PartNo" Then 'only verifying no duplicates if entering a new record
Call NoDuplicateSerial(Me, Cancel, "tblInfo") '"ME" sends the form to the module for duplication verification
End If
End Sub
which calls a module that I often use:
Code:
Sub NoDuplicateSerial(FormName1 As Form, Cancel, TableName)
Dim Answer As Variant
Answer = DLookup(FormName1.ActiveControl.ControlSource, TableName, FormName1.ActiveControl.ControlSource & " = '" & FormName1.ActiveControl & "'")
If Not IsNull(Answer) Then
MsgBox "Part number has already been entered in the database."
Cancel = True
FormName1.ActiveControl.Undo
End If
End Sub
Now, this works well, but I am having a small problem. After the error handling is complete, I have to press "ESC" in the combobox before I can go back to looking at existing records. Otherwise, I get a error 3058.
I understand that this means the record needs a primary key, but I thought the error handling code removed any entry? Why do I have to manually press "ESC" to stop this error? How do I get around this?
Thanks for the help!