GOto reocrd on subform

S

Stephen

I haev a main form that has the profile of a student
I have a subform with the list of classes that a student took in a
schoolyear. The subform is setup so that teh row that is selected (class
chosen) highlights the selected class row.

From a completely differnt form, I am able to see the grades that a student
received. When I choose a grade, I want to be able to automatically have
teh system open the student profile form (frmStudProf) and then navigate to
the appropriate record on the class subform (frmStudProfSubformClasses) such
that the appropriate row is highlighted.

I have been trying to use code from the grades form such as:

Set SearchRecord =
Forms![frmStudProf]![frmStudProfSubformClasses].Form.RecordsetClone

SearchRecord.FindFirst "[ClassRecordID] = " & Me.ClassRecordID

If Not SearchRecord.EOF Then
Forms![frmStudProf]![frmStudProfSubformClasses].Bookmark =
SearchRecord.Bookmark

Forms![frmStudProf]![frmStudProfSubformClasses].Form.Bookmark =
SearchRecord.Bookmark

Help..I can't seem to properly implement this....
 
S

Sandra Daigle

Hi Stephen,

Instead of testing the EOF property, you need to test the NoMatch property -
also, for the sake of shortening the form reference, you might want to use a
form object variable:

dim sfrm as form
dim SearchRecord as DAO.recordset

set sfrm=Forms![frmStudProf]![frmStudProfSubformClasses].Form
set SearchRecord=sfrm.recordsetclone

with SearchRecord
.FindFirst "[ClassRecordID] = " & Me.ClassRecordID
If Not .NoMatch then
sfrm.bookmark=.Bookmark
endif
end with
set sfrm=nothing
set SearchRecord=nothing

The With..End With clause also shortens the statements a bit. One other
thing, if ClassRecordID is a text field you need to wrap the test value in
quotes so that it will be properly formatted as a string when it gets to Jet
(the Database engine).

..FindFirst "[ClassRecordID] = """ & Me.ClassRecordID & """"

If this doesn't help then post back with an explanation of what is
happening, along with any errors you are getting.
 

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