Need help getting a form to display a certain record on opening

R

Ralph Malph

I have a form with 2 subforms in it. The main form is linked to a table
called "ClassSesYear" and has a field called "Class". When the form opens I
want it to display the last record in which the field of "Class" =
"theclassname". How do I do this. I have tried the following code, but I keep
getting a runtime error '3251': Operation is not supported for this type of
object. When I click on the debug button it takes me to my ".findlast" code
line. I have tried several different variations on the syntex for this
command but I get the same error every time. Any ideas on how to get this to
work?

Start Code sample:

Private Sub Form_Load()

Dim RST As Recordset
Dim FindString As String

Set RST = CurrentDb.TableDefs("ClassSesYear").OpenRecordset

With RST

FindString = "Class = """ & "DEH 2802L" & """"


..FindLast FindString

Set RST = Nothing

End With


End Sub

End Code Sample:

Thanks for the help,

Ralph Malph
 
Top