finding a record in continuous forms

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form of student records (name, teacher, etc.) with a command button
that opens a second form (modal) which is set in continuous forms design. It
shows about 10-12 records, with the student's record being somewhere in the
list.

When this second form is opened from the first form, I'd like the active
cell to be one with the student's name in the name field, so as to
immediately draw your eye to the student's record (so you don't have to
visually "search" for it). It defaults to the top left cell/field of course.

Each student record has a StudentID field (primary key), so I should be able
to "go to the record where the studentID is equal to the studentID in the
first form."

But I don't know how to code that. Anyone help?

Thanks in advance.

Jerry
 
suggest you add code to the second form's Load event procedure, to find the
record that matches the current record in the first form. something like

Me.Recordset.FindFirst "PrimaryKeyFieldName = " _
& Forms!FirstFormName!PrimaryKeyFieldName

the above code assumes that the primary key field is a Number data type. if
it's Text data type, then you need to change the syntax to

Me.Recordset.FindFirst "PrimaryKeyFieldName = '" _
& Forms!FirstFormName!PrimaryKeyFieldName & "'"

in either case, substitute the correct field names and form name, of course.

hth
 
thanks, Tina. Exactly what I needed!

Jerry

tina said:
suggest you add code to the second form's Load event procedure, to find the
record that matches the current record in the first form. something like

Me.Recordset.FindFirst "PrimaryKeyFieldName = " _
& Forms!FirstFormName!PrimaryKeyFieldName

the above code assumes that the primary key field is a Number data type. if
it's Text data type, then you need to change the syntax to

Me.Recordset.FindFirst "PrimaryKeyFieldName = '" _
& Forms!FirstFormName!PrimaryKeyFieldName & "'"

in either case, substitute the correct field names and form name, of course.

hth
 
If you use the WHERE argument of the OpenForm method, you won't need code in
the pop up. You will only see the record(s) you are looking for.

This method is more efficient than the other recommended method,
particularly if you are using a linked ODBC table.
 
Back
Top