Can I do this?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi
The following is a code to run Find method of a recordset "rstOrder". I want to find the position of the record in my table Orders, whose OrderID equals to the value of a text box "txtOrderID" on a Form, but the debug tells me that no such a method, where is wrong? what is the right method

rstOrder.Find "OrderID=" & txtOrderID.Valu

Many thanks
Goodman
 
Try ...

rstOrder.FindFirst




--
Cheryl Fischer
Law/Sys Associates
Houston, TX

Goodman said:
Hi,
The following is a code to run Find method of a recordset "rstOrder". I
want to find the position of the record in my table Orders, whose OrderID
equals to the value of a text box "txtOrderID" on a Form, but the debug
tells me that no such a method, where is wrong? what is the right method?
 
Hi,Cheryl:
thanks!
Do you mean this way?
rstOrder.FindFirst "OrderID=" & txtOrderID.Value

I tried your this method but stil doesnt work, it says doent support this object
can you show me how to do it properly in details?

Goodman
 
First, you will need to have a reference set to the Microsoft DAO Object
Library which is specific to your version of Access (3.51 for Access 97 or
3.6 for Access 2000 and newer). Then, in the Click event of a command
button, use code like the following air-code (meaning I have not tested it
for you):

Dim MyDB as DAO.Database
Dim rsOrder as DAO.Recordset
Dim strSQL as String

Set MyDB = CurrentDB
strSQL = "Select * from tblOrders"
Set rsOrder = MyDB.OpenRecordset(strSQL, dbOpenDynaset)

rsOrder.FindFirst "OrderID=" & txtOrderID.Value

If rsOrder.NoMatch then
MsgBox "Your search value not found"
else
' do something else
End If

Additional information on DAO Find Methods can be found at:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dao360/html
/damthfindfirst.asp

This page will lead you to other links concerning DAO
 
-----Original Message-----
Hi,
The following is a code to run Find method of a
recordset "rstOrder". I want to find the position of the
record in my table Orders, whose OrderID equals to the
value of a text box "txtOrderID" on a Form, but the debug
tells me that no such a method, where is wrong? what is
the right method?
rstOrder.Find "OrderID=" & txtOrderID.Value

Many thanks!
Goodman
.
Hi Goodman, I think you want to use

rst.FindFirst "OrderID=" & txtOrderID.Value

Luck
Jonathan
 
I still have the problem. Error info: "Run-time error '3251': Operation is not supported for this type of object". Below is part of my codes:

Dim dbsBodyworks As DAO.Database
Dim rstOrder, rstOrderDetails As DAO.Recordset

Set dbsBodyworks = CurrentDb
Set rstOrderDetails = dbsBodyworks.OpenRecordset("OrderDetails")
Set rstOrder = dbsBodyworks.OpenRecordset("Orders")

rstOrder.FindFirst "OrderID=" & txtOrderID.Value

Thanks!
Goodman
 
Back
Top