Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2005
    Posts
    46

    Unanswered: Checking for duplicates

    On a form I have textbox1

    On the after_update() I would like to run a check against a field in a table

    field1 - table1

    If the data already exists then a msgbox would appear telling me that is does and if dosnt exist then a msgbox would appear telling me that it didnt

    Pretty simple you would think.

    Can any one help with this.

  2. #2
    Join Date
    Feb 2005
    Posts
    46
    Sorted this out
    Created a query that selected records from table where field1 = textbox1

    on afterupdate()

    I then used

    dim num1 as integer

    num1 = dcount("field1","query1")
    if num1 = 1 then
    msgbox("This record exists")
    end if
    if num1 = 0 then
    msgbox("this record does not exist")
    end if

  3. #3
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    What if num1 = 2 (there are 2 records that match...)

    You might want to use:
    Code:
    If num1 = 0 Then
    'doesn't exist
    Else
    'does exist
    End If
    Always best to cover your a** whenever you can
    George
    Home | Blog

Posting Permissions

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