کد PHP:
strSQL = " select [SN] where sn=txtb1.value and out_date=(select max(last_Out) from [GM$] " & ComboBox3.Text
Dim cnn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim strSQL As String, strsql1 As String, strsql2 As String
Dim fpath As String
Dim str As String
Set cnn = New ADODB.Connection
Set rs = New ADODB.Recordset
fpath = ThisWorkbook.Path & Application.PathSeparator & ThisWorkbook.Name
str = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=""" _
& fpath & """;Extended Properties=""Excel 12.0 Xml;HDR=YES"";"
strSQL = "select max([Out_Date]) from [GM$]" & _
"where [GM$].[sn]= '" & ComboBox1.Value & "'"
cnn.Open str
rs.Open strSQL, cnn
Private Sub CommandButton1_Click()
Dim cnn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim strSQL As String
Dim fpath As String
Dim str As String
Set cnn = New ADODB.Connection
Set rs = New ADODB.Recordset
fpath = ThisWorkbook.Path & Application.PathSeparator & ThisWorkbook.Name
str = "provider=microsoft.ace.oledb.12.0;data source=""" & fpath & """;extended properties=""excel 12.0"";"
strSQL = "select * from [GM$]"
cnn.Open str
rs.Open strSQL, cnn
rs.Filter = "sn= '" & txtb1.Value & "' or entrance_date >= '" & txtb2.Value & "'"
Sheets("report").Range("report").Clear
Do While Not rs.EOF
cnn.Execute "INSERT INTO [report$] ([sn],[model],[last_out],[entrance_date],[out_date],[complete],[ownership],[day],[month],[year],[operation_time],[disassembling]) " & " values ('" & rs!sn & "','" & rs!model & "','" & rs!last_out & "','" & rs!entrance_date & "','" & rs!Out_date & "','" & rs!complete & "','" & rs!Ownership & "','" & rs!day & "','" & rs!month & "','" & rs!year & "','" & rs!operation_time & "','" & rs!disassembling & "')"
rs.MoveNext
Looprs.MoveFirst
End Sub
کامنت