Trying to autopopulate a line item number in a subform

13 views Asked by At

I have the below code in the BeforeInsert event of a subform. I am trying to sequentially autopopulate a "LineItemNumber" field for each Sales Order (from the main/parent form). Below is the code I have:

Private Sub Form_BeforeInsert(Cancel As Integer)
    Me.LineItemNumber = Nz(DMax("LineItemNumber", "tblSOLineItems", SalesOrderID = " & [SalesOrderID]), 0) + 1
End Sub

When it runs I get the compile error: Expected: list separator or ).

But I can't figure out what I am missing?

Tried various " and adding brackets, parentheses, etc. but can't figure this out!

0

There are 0 answers