Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    4 Star Lounger
    Join Date
    Mar 2005
    Location
    Leicestershire, United Kingdom
    Posts
    506
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Lookup last record and its contents in a particula (2000)

    |Is there a way to look at the last record in a table too sere the contents of a particular field. i will then use this to perform an action is they are not the same.
    Best Regards,

    Luke

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Lookup last record and its contents in a particula (2000)

    Do you mean the *last* record or the *previous* record?

  3. #3
    4 Star Lounger
    Join Date
    Mar 2005
    Location
    Leicestershire, United Kingdom
    Posts
    506
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Lookup last record and its contents in a particula (2000)

    The lst record where StPropertyId = PropertyID
    Best Regards,

    Luke

  4. #4
    4 Star Lounger
    Join Date
    Mar 2005
    Location
    Leicestershire, United Kingdom
    Posts
    506
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Lookup last record and its contents in a particula (2000)

    The last record where StPropertyID = PropertyID

    I want to be able to check if the boardstatus = stnewboardstatus on that record and if boardtag = stnewboardtag
    Best Regards,

    Luke

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Lookup last record and its contents in a particula (2000)

    And how is "last" defined? Can we use a date/time field for this, or an autonumber field?

  6. #6
    4 Star Lounger
    Join Date
    Mar 2005
    Location
    Leicestershire, United Kingdom
    Posts
    506
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Lookup last record and its contents in a particula (2000)

    autonumber field.
    Best Regards,

    Luke

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Lookup last record and its contents in a particula (2000)

    What is the name of the AutoNumber field?

  8. #8
    4 Star Lounger
    Join Date
    Mar 2005
    Location
    Leicestershire, United Kingdom
    Posts
    506
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Lookup last record and its contents in a particula (2000)

    STID
    Best Regards,

    Luke

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Lookup last record and its contents in a particula (2000)

    One way is to use DMax and DLookup. If I interpret your info correctly:

    Dim maxSTID
    Dim oldBoardStatus
    Dim oldBoardTag
    maxSTID = DMax("STID", "Name of table", "PropertyID = " & stPropertyID)
    oldBoardStatus = DLookup("BoardStatus", "Name of table", "STID = " & maxSTID)
    oldBoardTag = DLookup("BoardTag", "Name of table", "STID = " & maxSTID)

  10. #10
    4 Star Lounger
    Join Date
    Mar 2005
    Location
    Leicestershire, United Kingdom
    Posts
    506
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Lookup last record and its contents in a particula (2000)

    How do I do the following:

    If BoardStatus = oldBoardStatus & BoardTag <> oldBoardTag Then

    I want to be able to say:

    If the Boardtstaus box on the form is the same as and the boardtag field is not the same as oldboard tag then to create a new record.

    However the current method still creates a new record regardless.
    Best Regards,

    Luke

  11. #11
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Lookup last record and its contents in a particula (2000)

    Please provide more information. Where do you have this code? In the On Click event procedure of a command button, or in an event procedure of the form, or ...?

  12. #12
    4 Star Lounger
    Join Date
    Mar 2005
    Location
    Leicestershire, United Kingdom
    Posts
    506
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Lookup last record and its contents in a particula (2000)

    It is in the onclick event on a form frmProperty
    Best Regards,

    Luke

  13. #13
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Lookup last record and its contents in a particula (2000)

    Do you really mean the On Click event of the form itself? <img src=/S/scratch.gif border=0 alt=scratch width=25 height=29>

  14. #14
    4 Star Lounger
    Join Date
    Mar 2005
    Location
    Leicestershire, United Kingdom
    Posts
    506
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Lookup last record and its contents in a particula (2000)

    the onclick event of a command button, sorry
    Best Regards,

    Luke

  15. #15
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Lookup last record and its contents in a particula (2000)

    Something like this?

    Private Sub cmdWhatever_Click()
    Dim maxSTID
    Dim oldBoardStatus
    Dim oldBoardTag
    maxSTID = DMax("STID", "Name of table", "PropertyID = " & stPropertyID)
    oldBoardStatus = DLookup("BoardStatus", "Name of table", "STID = " & maxSTID)
    oldBoardTag = DLookup("BoardTag", "Name of table", "STID = " & maxSTID)
    If Me.BoardStatus = oldBoardStatus and Me.BoardTag <> oldBoardTag Then
    RunCommand acCmdRecordsGoToNew
    End If
    End Sub

Page 1 of 2 12 LastLast

Posting Permissions

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