|
Sub 开始()
Dim bt$, CNN, RS, SQL$, TJ$, i%, NewTime
bt = " [WRN#],班次,录入员,生产线,品种,取样时间,吸碘值,吸油值,[325#水洗],[200#水洗],[100#水洗],[35#水洗],[10#粒子],最大颗粒强度,平均颗粒强度,最小颗粒强度,水分,倾注密度,罐号,温度"
For i = 2 To 4 Step 2
TJ = TJ & Cells(1, i - 1) & "='" & Cells(1, i) & "' and "
Next
TJ = Left(TJ, Len(TJ) - 4)
NewTime = Now + TimeValue("00:00:03") '为了测试方便写3秒,根据你的需要自己更改
Set CNN = CreateObject("ADODB.Connection")
Set RS = CreateObject("adodb.Recordset")
CNN.Open "provider=microsoft.ace.oledb.12.0;data source=" & ThisWorkbook.Path & "\数据库.accdb"
SQL = "select top " & [f1] & bt & " from 生产命令单 where " & TJ & " order by id desc"
[a5:t999] = ""
Range("A5").CopyFromRecordset CNN.Execute(SQL)
[f5:f999].NumberFormatLocal = "hh:mm:ss"
Set RS = Nothing
Set CNN = Nothing
Application.OnTime NewTime, "开始"
End Sub
Sub 结束()
Application.OnTime EarliestTime:=Now + TimeValue("00:00:01"), Procedure:="开始", Schedule:=False
End Sub
|
|