Re: the value of the last record

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Allen Browne (AllenBrowne_at_SeeSig.Invalid)
Date: 10/18/04


Date: Mon, 18 Oct 2004 19:11:35 +0800

Normally a subform is bound to a table that is related to the main form's
table. The field in the subform's table that relates to the main form's
table is called the foreign key. Substitute the name of this field in the
expression.

Max() will not work in this context.

If necessary, use the AfterUpdate event of the subform to recalc the main
form. The code for the event procedure would be:
    Me.Parent.ReCalc

-- 
Allen Browne - Microsoft MVP.  Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Liat" <liat_oren@yahoo.co.uk> wrote in message
news:A1BA9614-58DF-408D-8814-3B34E035109F@microsoft.com...
> Thank you very much for your answer.
>
> What is the NameOfSubform'sForeignKey?
>
> I just used the Max(), what is the difference?
>
> How can I ReCalc after data was entered?
>
> Thanks a lot,
> Liat
>
> "Allen Browne" wrote:
>
>> Use DMax() to lookup the subform's table and get the maximum value of the
>> date field.
>>
>> The ControlSource of the text box on the main form will be:
>> =DMax("NameOfDateField", "NameOfSubform'sTable",
>>     "[NameOfSubform'sForeignKey] = " & Nz([NameOfMainForm'sPrimaryKey], 
>> 0)
>>
>> After changes in the subform, you may need to ReCalc the main form (or 
>> move
>> record) before it displays the new value.
>>
>> "Liat" <liat_oren@yahoo.co.uk> wrote in message
>> news:1C3DF292-769E-4DD3-9A4B-B3AF803FF34F@microsoft.com...
>> >
>> > I have a form and a sub form.
>> > One of the fields in the sub forms is date. I have some records in the 
>> > sub
>> > form for each record in the main form (one to many relation)
>> > I would like to have the date of the last record of the sub form.
>> >
>> > How can I get this value?
>> >
>> > Thanks a lot,
>> > Liat 


Relevant Pages

  • Re: Subform Totals
    ... In the main form I had some code which restricted the source of the subform ... For each of these fields their is a total field in the form footer. ... The sub form is a bound to a view. ... The questions is why do the total fields in the form footer of the sub ...
    (microsoft.public.access.adp.sqlserver)
  • Re: Booking duplicates
    ... the subform will be bound to the OrderDetail table (not ... There is no error message and the code compiles. ... the sub form? ... Doug Steele, Microsoft Access MVP ...
    (microsoft.public.access.modulesdaovba)
  • Re: standard rel. rules between 2 main frms with 1-1 rel. and su
    ... TblAnswersToQuestions - Each responders to one or more of your ... AnswersToQuestionsID ... I set up an If statement to send the tab to a sub form in the Sometimes ... but Ctrl+Tab out of the subform into ...
    (microsoft.public.access.tablesdbdesign)
  • RE: Updating a field property
    ... frmCall Tracking - Issues Log>> SUB FORM ... in a subform, you have to reference the subform control name and it's form ... With your form in design view Select Format, Conditional Formatting ... fields) and the value you want to check for to change the backcolor to white. ...
    (microsoft.public.access.formscoding)
  • RE: Synchronizing Two Different Froms Please help.
    ... I do not want to filter the Patient's subform. ... If you want to filter the data that is placed in the sub form of the second ... it opens the pt form but with no ...
    (microsoft.public.access.forms)