Results 1 to 5 of 5
  1. #1
    Star Lounger
    Join Date
    Feb 2001
    Location
    New Zealand
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Prevention of Duplicate Data Entry (Office XP)

    Hi,

    I have a table called sb main data and a form linked to it called sb main data entry. This is a data entry screen and its purpose is to add new members. I want to be able to enter the telephone number and after pressing the enter key have a dialogue box pop up advising if the telephone number is already entered. If the number isn't already entered, then pressing enter should just highlight the next field for data input. I have been experimenting with dlookups in the "on enter" property on the form but just can't seem to get it to work. I did try making the telephone number the primary key and not allowing duplicates but this meant you didn't discover the data had already been entered until after the entire form was filled out. This is probably very simple but I am stuck!!! <img src=/S/confused.gif border=0 alt=confused width=15 height=20>

    I would really appreciate some help on this. Thanks....Peter

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Prevention of Duplicate Data Entry (Office XP)

    You need to add your DLookup code to the BeforeUpdate event of your telephone textbox. Therefore, if this DLookup finds a duplicate, you can pop a msgbox to notify the user, then cancel the update. The OnEnter event fires when you first move into a control, not when you enter data into the control.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. #3
    Star Lounger
    Join Date
    Feb 2001
    Location
    New Zealand
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Prevention of Duplicate Data Entry (Office XP)

    Thanks for that Mark. I see that but am now having trouble with the code. What I had written was OK (but not doing anything) but when I change it to the before update, the VB editor comes up with an error message. This is what i wrote..."Private Sub telephone_number_BeforeUpdate(Cancel As Integer)
    DLookup("telephone_number", "sb main data entry", "telephone_number = Forms!sb main data entry!telephone_number") Is Null
    End Sub.

    I am still new at the VB stuff so I think i have got it wrong somewhere. It is expecting an =, but I can't see why. More frustration!!!

  4. #4
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Prevention of Duplicate Data Entry (Office XP)

    Any time you have blanks in a name (be it a table, field, control, or whatever), you MUST enclose that name in brackets!
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  5. #5
    Star Lounger
    Join Date
    Feb 2001
    Location
    New Zealand
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Prevention of Duplicate Data Entry (Office XP)

    got it!!!

    thanks....Peter

Posting Permissions

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