subform to define details of main form

J

Jeff

Hi all

I have a form frmStudents
A subform sfrmTableChoice

My form frmStudents has all the fields relevant to the student.
sfrmTableChoice is in a table format and has two fields: flStudentId and
flStudentName.

I want to be able to click on the cell with the relevant student id number
and automatically change the fields in the mainform with the information for
that student.

At the moment, I'm using a listbox and it works great, but I like the style
of the table!

I was offered the following code by Jonathan Parminter (thanks Johnathan)
but I can't get it to work! I should tell you, I'm not a very competent
user of Access, I just want to make a good database for my school.

Any help you can provide is greatly appreciated, as I've tried many sites
and hints pages without any solution.

Thanks,

Jeff

Jonathan's code:

this may work....
use the subform form_oncurrent() event to run a find on
the main form recordset. use the following as an example...

****** code starts*****

private sub Form_OnCurrent()
dim strCriteria as string
dim frm as Access.Form
dim rst as dao.recordset

' set criteria to find record using primary key
' StudentID is field name
' txtStudentID is textbox name in subform
strCriteria="[StudentID]=" & txtStudentID

set frm=Forms("mainFormName")
set rst=frm.recordsetclone
rst.findfirst strCriteria
if not rst.nomatch then
frm.bookmark = rst.bookmark
end if

end sub

****** code ends *******

this is air code
 
Top