Duplicate value in field or relationship

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Donna Price

    Duplicate value in field or relationship

    I have a problem with a database which I've recently separated into several
    related tables. I have a main data entry form, which has several subforms
    on it on tabbed pages. The first subform is actually part of the main data
    table, however, when I try to add new data to the form all is OK until I
    reach the first tab page which has specific data (still on the main table),
    when you try to add data to this part of the form an error message relating
    to duplicate values in fields, indexes or relationships occurs.

    However, this doesn't happen if you put info in the main part of the form.
    Close the form. Open the form again and add the data on the subform now.
    All is OK.

    I know this must be something simple but I just can't work it out.

    Any help???

    D


  • Fletcher Arnold

    #2
    Re: Duplicate value in field or relationship

    "Donna Price" <donna.price@ti scali.co.uk> wrote in message
    news:40256112$1 _2@mk-nntp-2.news.uk.tisca li.com...[color=blue]
    > I have a problem with a database which I've recently separated into[/color]
    several[color=blue]
    > related tables. I have a main data entry form, which has several subforms
    > on it on tabbed pages. The first subform is actually part of the main[/color]
    data[color=blue]
    > table, however, when I try to add new data to the form all is OK until I
    > reach the first tab page which has specific data (still on the main[/color]
    table),[color=blue]
    > when you try to add data to this part of the form an error message[/color]
    relating[color=blue]
    > to duplicate values in fields, indexes or relationships occurs.
    >
    > However, this doesn't happen if you put info in the main part of the form.
    > Close the form. Open the form again and add the data on the subform now.
    > All is OK.
    >
    > I know this must be something simple but I just can't work it out.
    >
    > Any help???
    >
    > D[/color]

    I would imagine that it is to with the fact that the new record has not been
    saved. Try saving the record first or putting a button with
    Me.Dirty = False
    Me.sbfSub1.SetF ocus
    So the record is saved before taking you to the related record. If this
    does the trick, the answer might be to create a custom 'AddNew' button which
    creates a new saved record (possibly by popping up a modal unbound form to
    get essential details for the new record). Having the standard Access
    record navigation controls for form/subform and allowing additions for both
    can cause trouble.

    If this isn't the cause of the error, let us know.

    Fletcher


    Comment

    • Donna Price

      #3
      Re: Duplicate value in field or relationship

      Thanks for that. I have included a standard wizard-created 'Save' Button on
      the form and have used this to save the record before moving to the subform
      but the same thing happens. It's only on closing the form and then opening
      it again does it allow the data to be added.

      Adding the data in datasheet view creates no problems at all, so it
      definitely points to the form or it's query. I can't try any other things
      until tomorrow as I don't have the file with me. If you have any other
      ideas I'd appreciate it. I'm a real 'taught myself novice' at this, I'm
      afraid.

      Tks
      Donna


      Comment

      • Fletcher Arnold

        #4
        Re: Duplicate value in field or relationship

        "Donna Price" <donna.price@ti scali.co.uk> wrote in message
        news:402601d0_1 @mk-nntp-2.news.uk.tisca li.com...[color=blue]
        > Thanks for that. I have included a standard wizard-created 'Save' Button[/color]
        on[color=blue]
        > the form and have used this to save the record before moving to the[/color]
        subform[color=blue]
        > but the same thing happens. It's only on closing the form and then[/color]
        opening[color=blue]
        > it again does it allow the data to be added.
        >
        > Adding the data in datasheet view creates no problems at all, so it
        > definitely points to the form or it's query. I can't try any other things
        > until tomorrow as I don't have the file with me. If you have any other
        > ideas I'd appreciate it. I'm a real 'taught myself novice' at this, I'm
        > afraid.
        >
        > Tks
        > Donna[/color]


        Are you sure you need to actually close the form? What about moving back a
        record and then going forward agin so you are sure it's saved?

        It's hard to say without knowing much about your table structure but it
        sounds like there might be a field which is required and no duplicates are
        allowed (typically something like tblOrders.Order No) and this field has a
        default value of zero. When you create a new order, unless you specifically
        type the order number in - and perhaps this is hidden away and forgotten on
        another tab - the default value of zero is allocated which may already
        exist. It's this sort of thing which would cause Access to bleat about
        duplicate values.


        Fletcher


        Comment

        Working...