|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub 开始()
Dim bt$, CNN, RS, SQL$, TJ$, i%, NewTime
bt = " [WRN#],班次,录入员,生产线,品种,取样时间,吸碘值,吸油值,[325#水洗],[200#水洗],[100#水洗],[35#水洗],[10#粒子],最大颗粒强度,平均颗粒强度,最小颗粒强度,水分,倾注密度,罐号,温度"
If m = True Then m = False: Exit Sub
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")
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"
SQL = "select * from (" & SQL & ") order by [WRN#]"
[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 |
|