为什么不直接找呢? 代码: Option Explicit Dim rs As New ADODB.RecordsetPrivate Sub Combo1_click() Combo2.ListIndex = Combo1.ListIndex End SubPrivate Sub Combo2_click() Combo1.ListIndex = Combo2.ListIndex End Sub Private Sub Command1_Click() Dim sql As String sql = "select where " If rs.State = 1 Then rs.Close End If rs.CursorLocation = adUseClient rs.Open sql, conn, adOpenKeyset, adLockPessimistic DataGrid1.AllowAddNew = False DataGrid1.AllowDelete = False Set DataGrid1.DataSource = rs End Sub Private Sub Command3_Click() If rs.BOF Then MsgBox "没有查询的数据!" Unload Me Exit Sub End If If rs.EOF Then MsgBox "没有查询的数据!" Unload Me Exit Sub End If Set DataGrid1.DataSource = Nothing End Sub Private Sub Form_Unload(Cancel As Integer) Set DataGrid1.DataSource = Nothing End SubPrivate Sub Form_Load() Dim rs1 As New ADODB.Recordset Dim sql As String sql = "select" rs1.Open sql, conn, adOpenKeyset, adLockPessimistic End Sub
我忘了这个怎么用了 谁给说一下啊
代码:
Option Explicit
Dim rs As New ADODB.RecordsetPrivate Sub Combo1_click()
Combo2.ListIndex = Combo1.ListIndex
End SubPrivate Sub Combo2_click()
Combo1.ListIndex = Combo2.ListIndex
End Sub
Private Sub Command1_Click()
Dim sql As String
sql = "select where "
If rs.State = 1 Then
rs.Close
End If
rs.CursorLocation = adUseClient
rs.Open sql, conn, adOpenKeyset, adLockPessimistic
DataGrid1.AllowAddNew = False
DataGrid1.AllowDelete = False
Set DataGrid1.DataSource = rs
End Sub
Private Sub Command3_Click()
If rs.BOF Then
MsgBox "没有查询的数据!"
Unload Me
Exit Sub
End If
If rs.EOF Then
MsgBox "没有查询的数据!"
Unload Me
Exit Sub
End If
Set DataGrid1.DataSource = Nothing
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set DataGrid1.DataSource = Nothing
End SubPrivate Sub Form_Load()
Dim rs1 As New ADODB.Recordset
Dim sql As String
sql = "select"
rs1.Open sql, conn, adOpenKeyset, adLockPessimistic
End Sub
Adodc1.Recordset.Find "商品名称 = '" & Text1.Text & "'", , , 1就行了 这个完整的写法|?就是第一句 要回到记录最前 Adodc1.Recordset.MoveFirst然后呢 |假如没有找到的话 怎么写来的?
成立吗?
怎么能模糊查询?
questr = "select 卡号,社编号,姓名,部门,测试记录,测试日期,测试时间,备注" & " " & _
"from 表名" & " where [表名].姓名='" & Text1.Text & "' and [表名].测试日期 between '" & DTPicker1.value & "'and '" & DTPicker2.value & "'"
Data1.RecordSource = questr
Data1.Refresh