Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2004
    Posts
    5

    Unanswered: Paasing Max Value to Field on From

    Hi,

    I have this table [Details] that monitors a car's activity in and out of a company.

    Car No | KM out | Date out | Time out | KM in | Date in | Time In
    ------------------------------------------------------------------------
    11 | 22 | 12/12/2004 | 12:00 | 55 | 12/12/2004 | 13:00

    In a form [Details], I have a combobox of the availabe Car numbers where a user would select a car number. I want to:

    As soon as the user selects a car number from the combobox, the field of the KM out should automatically be filled by the value of KM in of the last time the car was used i.e. I have to get the maximum date and time for each car (because one car can be used in the same day several times).

    I know I have to fill the after_update function of the car No with this query

    Froms!Details.KMout= SELECT d1.KMin
    FROM details AS d1
    WHERE (((d1.TimeIn)=(SELECT Max (d2.TimeIn)
    FROM details AS d2
    WHERE d2.DateIn=(SELECT max(d3.datein)
    FROM Details AS d3
    where d3.carnumber=d2.carnumber)
    and d2.carnumber=d1.carnumber)));

    But i dont know how to do it in VB !

    Can someone help me please?
    Thank you,
    Mahi

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Check out the DMAX() function.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •