Remembering records when leaving a form

G

Guest

Hello all,
I have a continuous form called FORM1 with
in the On Click event of the detail section

DoCmd.OpenForm "FORM2", acNormal, , "([fieldid] =" & [fieldid] & ")",
acFormEdit, acWindowNormal, Me.Name

The table behind FORM1 has hundreds of records. So, I scroll down to one of
the last records and click on the record.

It opens a form FORM2 with more details (based upon the same table) with
"([fieldid]=& [fieldid] & ")" as the where condition.
FORM2 is in normal Single Form mode.

On FORM2 i do some changes and
on FORM2 i have a close-button with this code:

Dim strDoc As String
If Not IsNull(Me.OpenArgs) Then
strDoc = Nz(Me.OpenArgs, vbNullString)
End If
DoCmd.Close acForm, Me.Name, acSaveNo
If strDoc <> vbNullString Then
If CurrentProject.AllForms(strDoc).IsLoaded Then
Forms(strDoc).Requery
End If
End If

I closes the FORM2 and requeries the calling FORM1 to update changes made in
FORM2. OK this works.
The trouble is that requerying the calling form makes the first record on
that form current. So to see the changes a made in FORM2 i have to scroll
down in the list of FORM1 to see the effect of changes.
Is there a way to go right back to the record on which i clicked the On
Click event..?


Any help would be welcom.
 
T

tina

you could add code after the requery command to find the pertinent record,
as

Dim var As Variant

var = Me!fieldid
DoCmd.Close
With Forms!FORM1
.Requery
.Recordset.FindFirst "[fieldid] =" & var
End With

make sure that you assign the value of var *before* the DoCmd.Close action
that closes FORM2. also suggest you change the variable from Variant data
type to whatever data type "fieldid" is.

hth
 

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