Textbox equals certain field of last record

  • Thread starter Thread starter skusey
  • Start date Start date
S

skusey

Hi,
I have a form that displays all records from a table. In the footer
area of this form, I have sub-totals adding up all of the values in the
fields of each record. I need one of my sub-totals in the footer called
txtSumBroughtForward) to equal exactly the value of the most recent
record in the txtBroughtForward field.

I cannot work this out and any help would be great. Please note that I
am a novice at this and so using jargon, won't really help me with
this, so the more detailed the reply is, the better it is for me.

Many thanks,
Ben
 
Assuming the Records are sorted according to their entry this ought to do it

Open The Form in Design View
View the Code For the Form (View Menu -> Code)
Paste the Following:

'------------------ Code Start

Public Function LastBroughtForward() As Variant
Dim RsC As DAO.Recordset ' Requires reference to DAO 3.6 (3.5) Library -
must be added for Acc2K, else loaded by default

Set RsC = Me.RecordsetClone
RsC.Movelast
LastBroughtForward = RsC.Fields("txtBroughtForward").Value
Set RsC = Nothing
End Function
' --------------- Code End

Now Set the Control Source for txtSumBroughtForward to
=LastBroughtForward()
And you should be rolling

--
Pieter Wijnen

My feeble Access pages (good links though)
http://www.thuleeng.com/access
When all else fail try:
http://www.mvps.org/access
http://www.granite.ab.ca/
http://allenbrowne.com/
 

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

Back
Top