Auto value in a field

  • Thread starter Dimitris Nikolakakis
  • 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
 
A

Arvin Meyer

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top