Select a specific row on a form

  • Thread starter Thread starter Daniel
  • Start date Start date
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.
 
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
 
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)


.
 
Back
Top