Adodc1.RecordSource = "select * from 主表 where " & "检验日期 = '" & DTPicker2.Value & "'" & "order by cdate(检验日期),主键,样品号" Adodc1.Refresh 这是我程序中的一段,检验日期字段类型我用了字符串型,DTPicker2是一个日期控件
取DataGrid的数据,其实就是取Adodc里的Recordset的数据:Private Sub Command1_Click() Dim i As Long For i = 1 To Adodc1.Recordset.RecordCount Debug.Print Adodc1.Recordset("日期") Adodc1.Recordset.MoveNext Next End Sub
还一方法, For i = 1 To Adodc1.Recordset.RecordCount dagatrid1.col = n '===n为dagatrid1控件的日期那一列的列号 Debug.Print datagrid1.text adodc1.recordset.movenext next 某些时候这种方法不如楼上的好
取DataGrid的数据,其实就是取记录集的数据:Private Sub Command1_Click() Dim i As Long For i = 1 To Adodc1.Recordset.RecordCount Debug.Print Adodc1.Recordset("日期") Adodc1.Recordset.MoveNext Next End Sub
Adodc1.Refresh
这是我程序中的一段,检验日期字段类型我用了字符串型,DTPicker2是一个日期控件
Dim i As Long
For i = 1 To Adodc1.Recordset.RecordCount
Debug.Print Adodc1.Recordset("日期")
Adodc1.Recordset.MoveNext
Next
End Sub
For i = 1 To Adodc1.Recordset.RecordCount
dagatrid1.col = n '===n为dagatrid1控件的日期那一列的列号
Debug.Print datagrid1.text
adodc1.recordset.movenext
next
某些时候这种方法不如楼上的好
Dim i As Long
For i = 1 To Adodc1.Recordset.RecordCount
Debug.Print Adodc1.Recordset("日期")
Adodc1.Recordset.MoveNext
Next
End Sub
ADODC1.Recordset.Filter = "日期>" & Format(Date, "yyyy-mm-dd")
或
ADODC1.Recordset.Filter = "日期=" & Format(Date, "yyyy-mm-dd")
或
ADODC1.Recordset.Filter = "日期<" & Format(Date, "yyyy-mm-dd")
Then ...