Function AdNo() As String
Dim Rs As New ADODB.Recordset
Dim Conn As New ADODB.Connection
Dim I As Integer
Set Conn = CurrentProject.Connection
Rs.Open "select count(*) from co where mid(coNO,4,6)=format(date(),'yymmdd')", Conn, adOpenDynamic, adLockOptimistic
If Rs.EOF Then
I = 1
Else
I = Rs.Fields(0) + 1
End If
AdNo = "RG" & Format(Date, "yymmdd") & "-" & "CS" & Format(I + 1, "000")