Option Explicit
Public cn As New ADODB.Connection
Public rs As New ADODB.Recordset
Public sql, dBase As String
Public Function connect()
Set cn = New ADODB.Connection
dBase = App.Path & "\MDbase.mdb"
cn.Open "Driver={Microsoft Access Driver (*.mdb)};dbq=" & dBase
End Function
Public Function Pos_AutoNum()
rs.Open "select * from EMPFILE Order By EmpID DESC", cn, 3, 2
If rs.RecordCount = 0 Then
frmEmp.txtEmpID.Text = Format(Now, "myyyy")
Else
frmEmp.txtEmpID.Text = Format(Now, "myyyy") & Format(Right(rs!EmpID, 4) + 1, "")
End If
rs.Close
End Function
No comments:
Post a Comment