subform view

  • Thread starter Thread starter Eric
  • Start date Start date
E

Eric

Using VBA, I want to get a subform to open with a
particular record at the top of the form, but still allow
a vertical scrolling of all records viewable by the
subform's underlying SQL statement. How do I do it?
 
Use the OrderBy property of the form in the subform to poke the desired
record to the top.

For example, assuiming you want the top record to be the one where the ID
field contains 99, and then sort by Surname after that, you would code like
this:
Dim strSort As String
strSort = "([ID] = 99), [Surname]"
With Me.[YourSubformControlNameHere].Form
.OrderBy = strSort
.OrderByOn = True
End With

How it works.
The statement:
[ID] = 99
is True only for one record, and False for all others.
Access uses -1 for True, and 0 for False.
-1 gets sorted ahead of zero.

You cannot place the new record row at the top of the subform.
 
Back
Top