|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.
|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

This month, every Windows Secrets subscriber can download a one-chapter excerpt of Windows 7: The Missing Manual.Windows 7: The Missing Manual provides valuable information to help you overcome these difficulties in learning a new operating system. Subscribe today to download your free excerpt.
Do you mean the *last* record or the *previous* record?
The lst record where StPropertyId = PropertyID
Best Regards,
Luke
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
And how is "last" defined? Can we use a date/time field for this, or an autonumber field?
autonumber field.
Best Regards,
Luke
What is the name of the AutoNumber field?
STID
Best Regards,
Luke
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)
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
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 ...?
It is in the onclick event on a form frmProperty
Best Regards,
Luke
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>
the onclick event of a command button, sorry
Best Regards,
Luke
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