postermmxvicom
Programmer
I have a form and a subform, NewOrder and NewOrderSubform1.
The tables for these forms are Order and OrderRelease, respectively.
Order has fields OrderKey, OrderNumber
OrderRelease has fields OrderReleaseKey, FKOrderKey, ReleaseNumber
What I need is to have the field ReleaseNumber in NewOrderSubform1 to be 1 more than the max ReleaseNumber for whichever Order is referenced in NewOrder.
I have accomplished this with the following VBA in the OnCurrent Event for the subform:
The problem is when I take the NewOrder form to a new record (and the OrderNumber is blank on the form) I need the ReleaseNumber to be 1.
Typically, my attempted solutions to this have thrown "invalid use of null" or "Syntax error (missing operator) in query expression 'FKOrder ='."
I have tried both Nz and IsNull in various ways to no avail.
I can build an expression that checks for Null and does something simple like pop up a message box saying whether or not it is null, but then when I try that same switch but use it to set ReleaseNumber to 1 (for null cases) or to the max (for other cases)...it gives me one of those errors.
Any insight would be greatly appreciated.
Aaron
One last thing: Sometimes I wonder; "Is that someone's signature? Or do they type that at the end of each post?
The tables for these forms are Order and OrderRelease, respectively.
Order has fields OrderKey, OrderNumber
OrderRelease has fields OrderReleaseKey, FKOrderKey, ReleaseNumber
What I need is to have the field ReleaseNumber in NewOrderSubform1 to be 1 more than the max ReleaseNumber for whichever Order is referenced in NewOrder.
I have accomplished this with the following VBA in the OnCurrent Event for the subform:
Code:
Me.ReleaseNumber.DefaultValue = DMax("ReleaseNumber", "OrderRelease", "FKOrder = " & DLookup("OrderKey", "Order", "OrderNumber = " & Forms!NewOrder.OrderNumber.Value)) + 1
The problem is when I take the NewOrder form to a new record (and the OrderNumber is blank on the form) I need the ReleaseNumber to be 1.
Typically, my attempted solutions to this have thrown "invalid use of null" or "Syntax error (missing operator) in query expression 'FKOrder ='."
I have tried both Nz and IsNull in various ways to no avail.
I can build an expression that checks for Null and does something simple like pop up a message box saying whether or not it is null, but then when I try that same switch but use it to set ReleaseNumber to 1 (for null cases) or to the max (for other cases)...it gives me one of those errors.
Any insight would be greatly appreciated.
Aaron
One last thing: Sometimes I wonder; "Is that someone's signature? Or do they type that at the end of each post?