|
修改rivate Sub Requisition_Click()
Dim Con1 As ADODB.Connection
Dim Rec1 As ADODB.Recordset
Dim RequisitionCode As String
Dim tkSQL As String
' Set Con1 = New Connection
Set Rec1 = New Recordset
Set Con1 = CurrentProject.Connection
RequisitionCode = Format(Date, "YYYY") & Format(Date, "mm") & Format(Date, "dd")
tkSQL = "SELECT TblRequisition.ChrRequisitionCode " & _
"FROM TblRequisition " & _
"WHERE (((TblRequisition.ChrRequisitionCode) Like """ & RequisitionCode & "%" & """)) " & _
"ORDER BY TblRequisition.ChrRequisitionCode DESC;"
Rec1.Open tkSQL, Con1, adOpenKeyset, adLockOptimistic
If Rec1.RecordCount < 1 Then
RequisitionCode = RequisitionCode & "01"
Else
RequisitionCode = RequisitionCode & Format(Right(Rec1![ChrrequisitionCode], 2) + 1, "0#")
End If
Me.CboRequisitionCode = RequisitionCode
' Con1.Close
' Set Con1 = Nothing
End Sub
|
|