custom search...

  • Thread starter Thread starter webmaster
  • Start date Start date
W

webmaster

I've built a custom search form that is used by many different forms in
our database. The search works fine. My problem is that I need to
change the current record of one form (the products form, the form that
opens the search form via command button) from the search form. The
search form finds one of our products based on user selection in a list
box (the primary key is what is returned). I desire to get the record
that was selected in the search form, based on the primary key that it
returns, and move the products form to the appropriate row. Im having a
hard time explaining this...Does anyone understand?
 
Just use the openform "where" clause.

docmd.OpenForm "frmProducts",,,"id = " & me!id

The above will open the frmProducts to the given "id" supplied.
 
Thanks that worked well. This method selects only one record from the
db, because Im searching a primary key. How do I go about getting all
the records but focused on the searched record?

Thanks.
 
Thanks that worked well. This method selects only one record from the
db, because Im searching a primary key. How do I go about getting all
the records but focused on the searched record?

To accomplish what you want, we will now NOT restrict the records loaded,
but "move" the forms pointer to the record we want.

We can use:
docmd.Openform "frmProducts"
forms!frmProducts.RecordSet.FindFirst "id = " & me.id

I as a general rule remove navigation buttions, and load the form to ONE
record (no need to load up more data then the user needs).
However, the above should do the trick for you...
 
Back
Top