OldValue usage

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sahiliiit
    New Member
    • Apr 2010
    • 2

    #1

    OldValue usage

    I have a project wherein i have to take the CardID of an RFID as input. The problem i m facing is that I dont want the values of the cardid to be repeated so i want to have a case where the system compares the value of the new cardid and compare it with the previous value. If it is same, the new value should be discarded else it should be written in the database.
    I tried using the OLDVALUE command but i was not sure of the syntax.

    Kindly help me out.
  • TheSmileyCoder
    Recognized Expert Moderator Top Contributor
    • Dec 2009
    • 2322

    #2
    The oldvalue is something you use when your changing a record. It can be used if you want to make comparisons between the original value and the new value, before you make a save. From what I understand thats not what you want.


    It depends a bit on how you get this information (the CardID), but when you get it you can simply check if your table allready contains an entry for that cardID.
    Assumptions:
    Cards are stored in tbl_Cards
    cardID is a field in table tbl_Cards, and is unique.
    When you get your CardID input, you temporarily store it in a long variable, lngCardID

    You can then use:
    Code:
    If Dcount("*","tbl_Cards","CardID=" & lngCardID)>0 Then
      'CardID allready exists, do whatever you want
    Else
      'CardID is new, do whatever you want
    End If

    Comment

    Working...