Prevent Duplicate Entry within a Month

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Usman55
    New Member
    • Jan 2022
    • 4

    Prevent Duplicate Entry within a Month

    Hello

    I have an access database for transactions
    I want to prevent duplicate entry against any account
    Suppose i have an account (4422A) and i want it to pay only one in a month
    If i enter this account twice access don't allow this entry.


    please help me
    Thanks
    Last edited by NeoPa; Jan 22 '22, 03:46 AM. Reason: Fixed title.
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32653

    #2
    Hi Usman.

    Welcome to Bytes.com.

    I have approved your question as valid, yet I must point out that it makes little sense and everyone will find it hard to understand what you want as you tell us so little.

    You say you want to prevent any duplicate entries, then you go on to say they are already prevented as indicated by the reported error message.

    You will need to explain your problem very much more clearly if you expect anyone to be able to help you. There's no doubt we'd like to if only your question made sense. Unfortunately ...

    Comment

    • isladogs
      Recognized Expert Moderator Contributor
      • Jul 2007
      • 483

      #3
      I'll try interpreting what I think you mean...

      I want to prevent duplicate entry against any account
      Suppose i have an account (4422A) and i want it to pay only one in a month
      If i enter this account twice access don't allow this entry.


      You can easily prevent duplicate entries by indexing the account field and specifying no duplicates
      However, I think you mean that it would be OK to pay that account again the following month.

      So, you could use a field called YearMonth or similar where this month would be 2201 & Feb 2022 would be 2202

      Now you could validate entries using a DCount expression. Something like:

      Code:
      If DCount("Payment", "tblPayments", "AccountID = " & Me.AccountID And YearMonth = Format(Date,"yymm"))=0 Then
        'allow payment
      End If
      This undoubtedly needs modifying but it might get you started

      EDIT Crossposted on at least two other forums
      Last edited by isladogs; Jan 22 '22, 01:56 AM.

      Comment

      Working...