freenet_2k@hotmail.c
Registered User.
- Local time
- Today, 01:18
- Joined
- Sep 26, 2008
- Messages
- 20
Hi All,
Two weeks ago I was able to get the help I needed to finish a project which had a deadline that was fast approaching. I'd like to start by saying thanks to all of you wonderful and helpful folks on this forum. You saved my job! Now I have a new situation/problem and once again, my deadline is fast approaching. I have some code that basically returns a custom error msg when a user tries to enter a new inventory item # that already exists in a table. The msg box instructs the user to add the characters "DUP-" in front of the item # to prevent duplicate entries on the table. That all works great, but instead of popping up an error msg, I'm trying to make the code automatically add the characters "DUP-" to the front of the number that they entered and I can't figure out how to do it or if it's even possible. Can anyone help me out or at least point me in the rifght direction? Here's the existing code. Thesection I need to modify is below "If Err.Number = 3022 Then" (obviously).
Thanks again to everyone who comes here to help out morons like me!
Two weeks ago I was able to get the help I needed to finish a project which had a deadline that was fast approaching. I'd like to start by saying thanks to all of you wonderful and helpful folks on this forum. You saved my job! Now I have a new situation/problem and once again, my deadline is fast approaching. I have some code that basically returns a custom error msg when a user tries to enter a new inventory item # that already exists in a table. The msg box instructs the user to add the characters "DUP-" in front of the item # to prevent duplicate entries on the table. That all works great, but instead of popping up an error msg, I'm trying to make the code automatically add the characters "DUP-" to the front of the number that they entered and I can't figure out how to do it or if it's even possible. Can anyone help me out or at least point me in the rifght direction? Here's the existing code. Thesection I need to modify is below "If Err.Number = 3022 Then" (obviously).

Code:
Private Sub SbmtNewItem_Click()
'DoCmd.Maximize
'Go to section ERRORTRAP if error occurs
On Error GoTo ErrorTrap
Dim MfgAfterNewSubmit As String
'Create a variable to hold the manufac number
MFGCATALOGNUM.SetFocus
MfgAfterNewSubmit = MFGCATALOGNUM.Text
'Close this AddNewItemForm and go back to the Main form
DoCmd.Close
'On Main form clear out the manufac number, requery the combobox, and reset the value from the variable
Forms!Main!Combo61.Undo
Forms!Main!Combo61.Requery
Forms!Main!Combo61.Text = MfgAfterNewSubmit
ErrorTrap:
If Err.Number = 3021 Then
Err.Clear
End If
If Err.Number = 3022 Then
MsgBox "Duplicate Mfg Catalog Number detected. Please place DUP- at the beginning of your new catalog Number. (Example: DUP-1234)"
End If
End Sub