DAO locating a specific record w/in recordset

casey

Registered User.
Local time
Today, 14:07
Joined
Dec 5, 2000
Messages
448
Hello all,

Is there a way to find a specific record using DAO within a recordset? (Like GotoRecord for DAO). I have a procedure to update the [quantity] of a record if its ProductID equals a specific number. Is it possible to go to that specific record and update its [quantity] without looping through the entire recordset and testing for the condition?

Thanks.
 
FIND is a function of the Recordset object that allows you to jump to the specified record.
 
Do you mean the Seek function?

Can anyone give me an idea as to how to use this?

I would like to Seek in a recordset for a ProductID = SomeNumber
 
casey,

Try this on an AfterUpdate or Command button

' ******************************
Dim db As Database
Dim rst as RecordSet
dim sql As String

Set db = CurrentDb
sql = "Select * " & _
"From Mytable " & _
"Where ProductID = " & Me.ProductID & ";"
set rst = db.OpenRecordset(sql)
If rst.EOF and rst.BOF Then
MsgBox("There is no such product.")
Exit Sub
Else
rst.Edit
'
' Your calculations etc ...
'
rst!quantity = (Your calculations etc ...)
rst.Update
set rst = Nothing
set Db = Nothing
End If
' ******************************

hth,
Wayne
 

Users who are viewing this thread

Back
Top Bottom