Find record without filter

  • Thread starter Thread starter CJ
  • Start date Start date
C

CJ

Hi groupies:

I have a form that lists projects one at a time. When you use a command
button, another form opens up that shows more data from the project.
However, when I use a command button to return to my first form, I view the
first record in the recordset. I would like to view the matching project but
without using the filter function so that I can still move between projects
on the first form.

I need some help with the code please.

Thanks in Advance.
CJ
 
CJ said:
I have a form that lists projects one at a time. When you use a command
button, another form opens up that shows more data from the project.
However, when I use a command button to return to my first form, I view the
first record in the recordset. I would like to view the matching project but
without using the filter function so that I can still move between projects
on the first form.


You are doing something to cause that, a Requery perhaps?
If that's how you are forcing the form to display the first
record, then you should save the current record's PK field
before the requery and find that record after the requery.
 
Hi Marshall, thanks for responding.

I don't actually requery but I do make the form close which is essentially
accomplishing the same thing. I would rather not keep the form open though.

There must be some way around this?!?!?!?!!!???
 
CJ said:
Hi Marshall, thanks for responding.

I don't actually requery but I do make the form close which is essentially
accomplishing the same thing. I would rather not keep the form open though.

There must be some way around this?!?!?!?!!!???


There usually is!!! ;-)

How about saving the current record's PK value in a safe
place before closing the form, then when you reopen the form
use OpenArgs to tell the form whch record to find.

The simplest, but not the safest, place to save a value is
in a Public variable in the declarations part of a standard
module. The code where the form is closed could be
something like:
savepk = Forms!theform.pkfieldname
DoCmd.Close acForm, "theform"

When you reopen the form, use this kind of statement:
DoCmd.OpenForm "theform", OpenArgs:=savepk

The form's Load event could then use code like:
If Not IsNull(Me.OpenArgs) Then
With Me.Recordset
If .RecordCount > 0 Then
.FindFirst "pkfieldname=" & Me.OpenArgs
If .NoMatch Then .MoveFirst
End If
End With
End If
 
Back
Top