字段
[Group] (values are ARTS , PRE-MED , PRE-ENG, ICS )
我想要关于名为RollNo的新领域的数据,如18AR01“
only 2 last digits of current year + iif([group]=ARTS,AR,iif([group]=PRE-MED,PM,iif([group]=PRE-ENG,PE,iif([group]=ICS,NULL,))))
这怎么可能?
您可以使用表单的BeforeInsert事件:
Dim Code As String
Dim Number As Integer
Code = Nz(Format(Date, "yy") & Switch(Me![Group] = "ARTS", "AR", Me![Group]= "PRE-MED", "PM", Me![Group] = "PRE-ENG", "PE"))
Number = Val(Nz(DMax("Right([RollNo], 2)", "YourTable", "[RollNo] Like '" & Code & "??'"))) + 1
Me!RollNo.Value = Format(Date, "yy") & Code & Format(Number, "00")