Select a specific row on a form

D

Daniel

I have a form diplaying a table in multiple forms view
(displayes all rows).

I want to set the current record in that form based on a
criteria selected by the user (like a quick search - the
user enters an item name or code and the form is set to
this item).

I tried using DoCmd.GoToRecord but it takes only row
number, so how can I find the row number on that form by
my criteria ?

I tried searching with RecordsetClone but it always
returns 1.
 
D

Dirk Goldgar

Daniel said:
I have a form diplaying a table in multiple forms view
(displayes all rows).

I want to set the current record in that form based on a
criteria selected by the user (like a quick search - the
user enters an item name or code and the form is set to
this item).

I tried using DoCmd.GoToRecord but it takes only row
number, so how can I find the row number on that form by
my criteria ?

I tried searching with RecordsetClone but it always
returns 1.

Suppose you have already built a criteria string such as
"ItemCode='abcd'", and stored it in variable strCriteria. Then you can
find the first matching record using code behind the form like this:

With Me.RecordsetClone
.FindFirst strCriteria
If .NoMatch Then
MsgBox "Sorry, no matching record was found."
Else
Me.Bookmark = .Bookmark
End If
End With
 
D

Daniel

Thank you !

-----Original Message-----


Suppose you have already built a criteria string such as
"ItemCode='abcd'", and stored it in variable strCriteria. Then you can
find the first matching record using code behind the form like this:

With Me.RecordsetClone
.FindFirst strCriteria
If .NoMatch Then
MsgBox "Sorry, no matching record was found."
Else
Me.Bookmark = .Bookmark
End If
End With

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top