这里有一个例子
Sub SeekX() Dim dbsNorthwind As Database
Dim rstProducts As Recordset
Dim intFirst As Integer
Dim intLast As Integer
Dim strMessage As String
Dim strSeek As String
Dim varBook As Variant Set dbsNorthwind = OpenDatabase("Northwind.mdb")
' You must open a table-type Recordset to use an index,
' and hence the Seek method.
Set rstProducts = _
dbsNorthwind.OpenRecordset("Products", dbOpenTable) With rstProducts
' Set the index.
.Index = "PrimaryKey" ' Get the lowest and highest product IDs.
.MoveLast
intLast = !ProductID
.MoveFirst
intFirst = !ProductID Do While True
' Display current record information and ask user
' for ID number.
strMessage = "Product ID: " & !ProductID & vbCr & _
"Name: " & !ProductName & vbCr & vbCr & _
"Enter a product ID between " & intFirst & _
" and " & intLast & "."
strSeek = InputBox(strMessage) If strSeek = "" Then Exit Do ' Store current book in case the Seek fails.
varBook = .Book .Seek "=", Val(strSeek) ' Return to the current record if the Seek fails.
If .NoMatch Then
MsgBox "ID not found!"
.Book = varBook
End If
Loop .Close
End With dbsNorthwind.CloseEnd Sub
其实过你要查找!有很多方法啊!
为什么吗用seek那!
你可以用
adore.open "select * from tablename where field="& value,...
如果是字符串
adore.open "select * from tablename where field='"& value &"'",...
时间
adore.open "select * from tablename where field=#"& value &"#",...
Sub SeekX() Dim dbsNorthwind As Database
Dim rstProducts As Recordset
Dim intFirst As Integer
Dim intLast As Integer
Dim strMessage As String
Dim strSeek As String
Dim varBook As Variant Set dbsNorthwind = OpenDatabase("Northwind.mdb")
' You must open a table-type Recordset to use an index,
' and hence the Seek method.
Set rstProducts = _
dbsNorthwind.OpenRecordset("Products", dbOpenTable) With rstProducts
' Set the index.
.Index = "PrimaryKey" ' Get the lowest and highest product IDs.
.MoveLast
intLast = !ProductID
.MoveFirst
intFirst = !ProductID Do While True
' Display current record information and ask user
' for ID number.
strMessage = "Product ID: " & !ProductID & vbCr & _
"Name: " & !ProductName & vbCr & vbCr & _
"Enter a product ID between " & intFirst & _
" and " & intLast & "."
strSeek = InputBox(strMessage) If strSeek = "" Then Exit Do ' Store current book in case the Seek fails.
varBook = .Book .Seek "=", Val(strSeek) ' Return to the current record if the Seek fails.
If .NoMatch Then
MsgBox "ID not found!"
.Book = varBook
End If
Loop .Close
End With dbsNorthwind.CloseEnd Sub
其实过你要查找!有很多方法啊!
为什么吗用seek那!
你可以用
adore.open "select * from tablename where field="& value,...
如果是字符串
adore.open "select * from tablename where field='"& value &"'",...
时间
adore.open "select * from tablename where field=#"& value &"#",...
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货