You don't want duplicate products in an order. I would do it in code
like the following...
Use the form's BeforeUpdate event and its NewRecord property.
Private Sub Form_BeforeUpdate(Cancel As Integer)
'If this is a new record
If Me.NewRecord Then
'Check if it has already been entered
If Not IsNull(DLookup("ProdID", "tblOrdLines", "ProdID=" _
& Me.cboProd)) Then
'It has so lets just add the quantity to it
CurrentDb.Execute "UPDATE tblOrdLines SET OrdQty = " _
& "OrdQty + " & Me.txtQty & " WHERE OrdID = " _
& Me.OrdID & " AND ProdID=" & Me.cboProd, dbFailOnError
Cancel = True
Me.Undo
End If
End If
End Sub
Of course change the table, field and control names to match yours.
- Jim
On Sun, 26 Sep 2004 20:10:05 GMT, DS <bo******@optonline.net> wrote:
Hi, I have an order entry form with a subform attached for order
details. Whenever you add a product to the Order Details subform and
then you try to add the same product again in won't let you. Which is
fine. The problem I'm having is that I'll be sing a scanner to enter
products and when you have two products in a row I need the subform to
make the quantity 2 not give me an error message that I already have the
product entered. I tried a work around by allowing duplicates, which
also works fine but now I have a product listed 2 or more times which
looks sloppy. Any solutions? If I write a Macro what would it say? If
I write code what would it say? Thanks Everyone,
DS
bo******@optonline.net