R
Ruth
I have a form that collects information for a after-market part to be
built. There are two combo boxes-- the first lists the Original Mfg.
Name, which filters the second box that lists the part numbers for
that mfg. The third is a text box where a serial number is entered.
The combination of the OEM part number (PN) and the aftermarket
producer's Serial Number (SN) make up the PartID. There are some other
information fields as well.
I created an append query that concatenates the PN and SN fields to
CellID which becomes the Key field in the primary table. I don't want
to see the append message each time, but if I turn off warnings, you
don't see the error message when the update fails. I don't think the
Dcount is working because the message box doesn't activate.
Here's the code I have now:
Private Sub btnAddCell_Click()
On Error GoTo btnAddCell_Err
' Turn Off Screen Display while code runs
DoCmd.Echo False, "Please wait while new cell is created "
' Turns on hourglass
DoCmd.Hourglass True
' Turns warning off
DoCmd.SetWarnings False
' Saves new record
DoCmd.RunCommand acCmdSaveRecord
'Checks for duplicate values that with make up Cell ID
If DCount("*", "[tblCellEntry]", [PN] = """ & Me.PN & """ And [SN]
= """ & Me.SN & """) = 0 Then
' RunsQuery to Add New Cell
DoCmd.OpenQuery "qryAddNewCell", acViewNormal, acEdit
' Closes append query
DoCmd.Close acQuery, "qryAddNewCell"
' Closes New Cell Form
DoCmd.Close acForm, "frmNewCell"
' Turns off hourglass
DoCmd.Hourglass False
' Turns warnings back on
DoCmd.SetWarnings True
' Activates Screen display again
DoCmd.Echo True, ""
Else
MsgBox "A cell already exists with this S/N. Choose a new S/N
or return to the Main Menu and Edit Existing Cell",
(vbDefaultButton1), "Duplicate S/N"
End If
btnAddCell_Exit:
Exit Sub
btnAddCell_Err:
MsgBox "A cell already exists with this S/N. Choose a new S/N or
return to the Main Menu and Edit Existing Cell", (vbDefaultButton1),
"Duplicate S/N"
Resume btnAddCell_Exit
End Sub.
I'm sure there's a glaring error there somewhere, but I'm not finding
it!
Other ideas for how to accomplish this?
Many thanks in advance,
Ruth
built. There are two combo boxes-- the first lists the Original Mfg.
Name, which filters the second box that lists the part numbers for
that mfg. The third is a text box where a serial number is entered.
The combination of the OEM part number (PN) and the aftermarket
producer's Serial Number (SN) make up the PartID. There are some other
information fields as well.
I created an append query that concatenates the PN and SN fields to
CellID which becomes the Key field in the primary table. I don't want
to see the append message each time, but if I turn off warnings, you
don't see the error message when the update fails. I don't think the
Dcount is working because the message box doesn't activate.
Here's the code I have now:
Private Sub btnAddCell_Click()
On Error GoTo btnAddCell_Err
' Turn Off Screen Display while code runs
DoCmd.Echo False, "Please wait while new cell is created "
' Turns on hourglass
DoCmd.Hourglass True
' Turns warning off
DoCmd.SetWarnings False
' Saves new record
DoCmd.RunCommand acCmdSaveRecord
'Checks for duplicate values that with make up Cell ID
If DCount("*", "[tblCellEntry]", [PN] = """ & Me.PN & """ And [SN]
= """ & Me.SN & """) = 0 Then
' RunsQuery to Add New Cell
DoCmd.OpenQuery "qryAddNewCell", acViewNormal, acEdit
' Closes append query
DoCmd.Close acQuery, "qryAddNewCell"
' Closes New Cell Form
DoCmd.Close acForm, "frmNewCell"
' Turns off hourglass
DoCmd.Hourglass False
' Turns warnings back on
DoCmd.SetWarnings True
' Activates Screen display again
DoCmd.Echo True, ""
Else
MsgBox "A cell already exists with this S/N. Choose a new S/N
or return to the Main Menu and Edit Existing Cell",
(vbDefaultButton1), "Duplicate S/N"
End If
btnAddCell_Exit:
Exit Sub
btnAddCell_Err:
MsgBox "A cell already exists with this S/N. Choose a new S/N or
return to the Main Menu and Edit Existing Cell", (vbDefaultButton1),
"Duplicate S/N"
Resume btnAddCell_Exit
End Sub.
I'm sure there's a glaring error there somewhere, but I'm not finding
it!
Other ideas for how to accomplish this?
Many thanks in advance,
Ruth