moving to a certain record on a bound form...

  • Thread starter Thread starter Brad Pears
  • Start date Start date
B

Brad Pears

I have a data bound "main" customers form. I have developed a look- up form
for the cust where they can quickly enter some criteria and do search. This
"search" form is set as a pop-up. When the user selects the appropriate cust
record by highliting the area to the left of the actual record, they would
then click my custom "Edit Selected" button and then I close that "search"
form and right away issue a "docmd.applyfilter,,"where custid = 1234". This
works but by doing this when the user is back at the main form, the filter
is set for that record they selected from the "search" form only. They have
to remember to un-click the "filter" icon to view all the cust records.

Is there a way that when the user selects the record they want to work with
from my pop-up "search" form, that when that form closes, the main form will
simply re-position to display that record without me havaing to set a
filter?

Thanks,

Brad
 
Say a form is based on a table with a numeric primary key field named
ID.

The following code will reposition the form to the record (if any) with
ID=99, without using filtering.

(untested)

with me.recordsetclone
.findfirst "[ID]=99"
if not .nomatch then
' set the form's bookmark to the record's bookmark;
' this repositions the form to that recrd.
me.bookmark = .bookmark
endif
end with

Be careful to cut & paste - do not type it manually - or you will
probably lose some dots.

If a filter has been applied already, that code will only search the
filtered records. You could fix this by setting Me.FilterOn=False at
the start, if you wanted.

HTH,
TC (MVP Access)
http://tc2.atspace.com
 
Back
Top