Auto value in a field

  • Thread starter Thread starter Dimitris Nikolakakis
  • Start date Start date
D

Dimitris Nikolakakis

I have a table Orders with fields:
OrderID, TypeID, Date

I have a form FOffers where:

TypeID = "OFR" always
Date = Now()

and I want the field OrderID to take automatically the value:

SELECT MAX(Orders.OrderID)+1 FROM Orders WHERE Orders.TypeID="OFR"

How can I do this?

Thanks
 
It needs to be done from a form. In the AfterUpdate event of the TypeID
control.

Sub TypeID_AfterUpdate()
If Me.TypeID = "OFR" Then
Me.OrderIDDMax("[OrderID]","Orders")+1
Else
' Whatever the other value is.
End If
End Sub
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
Back
Top