Having subform show last entry on open

G

Guest

Ive build a simple database to keep progress notes on my clients. I have a
form for the client, and a sub form for the progress notes that is linked to
the client. The problem is when I open the client form, it automatically
shows the first notes for the progress notes subform. I would like it to
show the notes from our last meeting. How can I do that?

Jason
 
G

Guest

If you don't have a date/time field in the table with your notes that is the
record source for your sub form, you need one. Then order by that data/time
field in Descending order.
 
T

tina

does the ProgressNotes table have a Date/Time field? if so, you can set the
subform's OrderBy property to show the records in "reverse" order, in the
subform's Load event procedure, as

Private Sub Form_Load()

Me.OrderBy "DateTimeFieldName DESC"
Me.OrderByOn = True

End Sub

substitute the correct name of the date time field, of course. if you don't
have a date/time field in the ProgressNotes table, but have another field
that accurately reflects the order that records were entered, you can use
that field instead.

note: make sure you add the code to the *subform* Load event procedure, not
the main form.

hth
 
G

Guest

Thank you both for your response. Yes I do have a date field in the subform.
I entered your code you mentioned and changed the name of the field, but now
get a “compile error: Invalid use of property.†When it does this it
highlights the first “.OrderByâ€

Again, thanks for the help.

Jason
 
T

tina

oops, typo, sorry about that. try

Private Sub Form_Load()

Me.OrderBy = "DateTimeFieldName DESC"
Me.OrderByOn = True

End Sub

hth
 

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