DAO locating a specific record w/in recordset (1 Viewer)

casey

Registered User.
Local time
Today, 03:21
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.
 

Travis

Registered User.
Local time
Yesterday, 19:21
Joined
Dec 17, 1999
Messages
1,332
FIND is a function of the Recordset object that allows you to jump to the specified record.
 

casey

Registered User.
Local time
Today, 03:21
Joined
Dec 5, 2000
Messages
448
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
 

WayneRyan

AWF VIP
Local time
Today, 03:21
Joined
Nov 19, 2002
Messages
7,122
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

Top Bottom