Geoffrey said:
Does anyone know how to position on a record on a sub form.
Sub form is called EasyBookerSelectFlight
reccount = [EasyBookerSelectFlight].form.currentrecord
me.[EasyBookerSelectFlight].requery
docmd.gotorecord, acdataform, "EasyBookerSelectFlight", reccount
gets an error message
Syntactically, you can do it like this:
With Me!EasyBookerSelectFlight
reccount = .Form.CurrentRecord
.Requery
.SetFocus
End With
DoCmd.GoToRecord acActiveDataObject, , acGoTo, currentrecord
Thinking about this logically, though, this method *must* be unreliable,
since you cannot know that the same record will be in the same position
in the recordset -- or even present at all -- after you requery the
subform. A better approach is to capture the value of the current
record's primary key field, then go back to that record by finding the
primary key. Like this:
Dim RecID As Variant
With Me!EasyBookerSelectFlight.Form
RecID = !IDField.Value
.Requery
.Recordset.FindFirst "IDField = " & RecID
End With
Note that, if IDField is a text field, you have to change the FindFirst
criteria so that the value of RecID is enclosed in quotes; e.g.,
.Recordset.FindFirst _
"IDField = " & Chr(34) & RecID & Chr(34)