From: Joe Clark on
Hey y'all, I've got a form that lists all the Students in a class and
a link to "Edit Student Information" which opens a form to edit
individual records. The link uses the same type of code generated by
the form wizard and it automatically filters the records to the class.

The next thing I want to do is to open the new form to exactly the
record that was highlighted in the list. I can capture the list
position from the subform (SelTop) and I found a method called
"GoToRecord" that works like this to go to the 8th record:

DoCmd.GoToRecord acDataForm, "Student Data Entry", acGoTo, 8

But, one, it doesn't seem to work, and two, the records on the pop-up
form might be sorted differently so I'd rather search by value. Is
there a way I can activate "Find" on the new form? I don't want to
apply a filter because the other students in the class should still be
accessible.

From: strive4peace on
Hi Joe,

on the Load event of [Edit Student Information]
'~~~~~~~~~~~~~~

'set up Error Handler
On Error GoTo Proc_Err

'see if StudentList form is open
if not currentproject.allforms("StudentList_formname").IsLoaded then
exit sub
end if

dim f as form

set f = forms("StudentList_formname")

'save current record if changes were made
If f.dirty then f.dirty = false

'exit if user is not on a current record in that form
if f.NewRecord then exit sub

'declare a variable to hold the primary key value to look up
Dim mRecordID As Long

'set value to look up by what is selected
mRecordID = f.StudentID_controlname

'find the first value that matches
Me.RecordsetClone.FindFirst "StudentID_fieldname= " & mRecordID

'if a matching record was found, then move to it
If Not Me.RecordsetClone.NoMatch Then
Me.Bookmark = Me.RecordsetClone.Bookmark
End If

Proc_Exit:
Exit Sub

Proc_Err:
MsgBox Err.Description, , _
"ERROR " & Err.Number _
& " ProcedureName"

'press F8 to step through code and debug
'remove next line after debugged
Stop: Resume

Resume Proc_Exit

'~~~~~~~~~~~~~~`

WHERE
-ProcedureName is the name of the procedure that the code is in
(Form_Load) so if there is an error, you can see where it is




Warm Regards,
Crystal
*
(: have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*



Joe Clark wrote:
> Hey y'all, I've got a form that lists all the Students in a class and
> a link to "Edit Student Information" which opens a form to edit
> individual records. The link uses the same type of code generated by
> the form wizard and it automatically filters the records to the class.
>
> The next thing I want to do is to open the new form to exactly the
> record that was highlighted in the list. I can capture the list
> position from the subform (SelTop) and I found a method called
> "GoToRecord" that works like this to go to the 8th record:
>
> DoCmd.GoToRecord acDataForm, "Student Data Entry", acGoTo, 8
>
> But, one, it doesn't seem to work, and two, the records on the pop-up
> form might be sorted differently so I'd rather search by value. Is
> there a way I can activate "Find" on the new form? I don't want to
> apply a filter because the other students in the class should still be
> accessible.
>