finding a record in continuous forms

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
 
T

tina

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
 
G

Guest

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
 
P

Pat Hartman\(MVP\)

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.
 

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