N
Nick W
Hi All,
I am working on a database someone has created for processing orders.
There is one table for all transactions whether they are sales orders
or purchase orders. There is a field called ParentId which is being
used as the sale s or purchase order number. What I have done is added
two columns to this table called SalesReference and PurchaseReference
so that the Sales Order numbers are concurrent and the Purchase Order
numbers are concurrent. The form knows whether it is a sales order or
a purchase order by the CorS (Customer or Supplier) field. I've added
code to the Before Insert on the Order form as follows:
If Me.NewRecord And Me.CorS = "C" Then
Forms![frmTransactionHeader]![ParentId] = Nz(DMax("[SalesReference]",
"tblTransactionHeader") + 1, 0)
If Me.NewRecord And Me.CorS = "C" Then
Forms![frmTransactionHeader]![SalesReference] =
Nz(DMax("[SalesReference]", "tblTransactionHeader") + 1, 0)
If Me.NewRecord And Me.CorS = "S" Then
Forms![frmTransactionHeader]![ParentId] =
Nz(DMax("[PurchaseReference]", "tblTransactionHeader") + 1, 0)
If Me.NewRecord And Me.CorS = "S" Then
Forms![frmTransactionHeader]![PurchaseReference] =
Nz(DMax("[PurchaseReference]", "tblTransactionHeader") + 1, 0)
End If
End If
End If
End If
However it does not work, if I just have the following code it will
create the next Parent Id:
If Me.NewRecord Then
Forms![frmTransactionHeader]![ParentId] = Nz(DMax("[SalesReference]",
"tblTransactionHeader") + 1, 0)
Can anyone let me know where I'm going wrong,
Thanks in advance,
Nick
I am working on a database someone has created for processing orders.
There is one table for all transactions whether they are sales orders
or purchase orders. There is a field called ParentId which is being
used as the sale s or purchase order number. What I have done is added
two columns to this table called SalesReference and PurchaseReference
so that the Sales Order numbers are concurrent and the Purchase Order
numbers are concurrent. The form knows whether it is a sales order or
a purchase order by the CorS (Customer or Supplier) field. I've added
code to the Before Insert on the Order form as follows:
If Me.NewRecord And Me.CorS = "C" Then
Forms![frmTransactionHeader]![ParentId] = Nz(DMax("[SalesReference]",
"tblTransactionHeader") + 1, 0)
If Me.NewRecord And Me.CorS = "C" Then
Forms![frmTransactionHeader]![SalesReference] =
Nz(DMax("[SalesReference]", "tblTransactionHeader") + 1, 0)
If Me.NewRecord And Me.CorS = "S" Then
Forms![frmTransactionHeader]![ParentId] =
Nz(DMax("[PurchaseReference]", "tblTransactionHeader") + 1, 0)
If Me.NewRecord And Me.CorS = "S" Then
Forms![frmTransactionHeader]![PurchaseReference] =
Nz(DMax("[PurchaseReference]", "tblTransactionHeader") + 1, 0)
End If
End If
End If
End If
However it does not work, if I just have the following code it will
create the next Parent Id:
If Me.NewRecord Then
Forms![frmTransactionHeader]![ParentId] = Nz(DMax("[SalesReference]",
"tblTransactionHeader") + 1, 0)
Can anyone let me know where I'm going wrong,
Thanks in advance,
Nick