Results 1 to 5 of 5
  1. #1
    stevegreene1 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Apr 2014
    Posts
    3

    Odd behavior from append query, duplicate entries into table

    My append query is meant to take some data from public functions and some from a form in order to populate new entries to a maintenance work order database. It seems to work fine until I disable the warnings just before the openquery command. Here is the SQL code.
    Code:
    INSERT INTO WorkOrders ( Entered_Date, Entered_PC, Entered_User, Type, RequestedBy, Equipment, Description, RequiredCompletion, Status )
    SELECT Now() AS Expr1, getPC() AS Expr8, getUser() AS Expr9, [Forms]![NewMWO]![Combo1] AS Expr5, [Forms]![NewMWO]![Combo9] AS Expr6, [Forms]![NewMWO]![Combo17] AS Expr7, [Forms]![NewMWO]![Text26] AS Expr4, [Forms]![NewMWO]![DTPicker3] AS Expr3, 1 AS Expr2;
    The code used on the trigger for this query is:


    Code:
    Private Sub Command40_Click()
        Combo1.SetFocus
        If Not (Combo1.Text <> "") Then
            MsgBox "You must first select a MWO type."
            Exit Sub
        End If
        Combo9.SetFocus
        If Not (Combo9.Text <> "") Then
            MsgBox "You must enter a requestor."
            Exit Sub
        End If
        Combo11.SetFocus
        If Combo11.Text = "" Then
            MsgBox "Select a department, followed by location and equipment."
            Exit Sub
        End If
        Combo32.SetFocus
        If Combo32.Text = "" Then
            MsgBox "Select a location, followed by equipment."
            Exit Sub
        End If
        Combo17.SetFocus
        If Combo17.Text = "" Then
            MsgBox "Select a piece of equipment."
            Exit Sub
        End If
        Text26.SetFocus
        If Text26.Text = "" Then
            MsgBox "Enter a description of the problem."
            Exit Sub
        End If
        'DoCmd.SetWarnings (False)
        DoCmd.OpenQuery "AddWorkOrder"
        'DoCmd.SetWarnings (True)
    End Sub
    When I uncomment the two setWarning lines I get two entries to the table instead of one. Can anyone see what might be causing this? Thanks in advance for your suggestions!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    What is the warning message when there is only one entry?

    Are the two records identical?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    stevegreene1 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Apr 2014
    Posts
    3
    The warning message is the standard access messages for adding items to a table. The first says "You are about to run an append query that will modify data in your table." The second, says "You are about to add 1 row(s).".

    When I uncomment the lines to remove these warning messages, it runs on it's own, but I get two identical entries (Except for the AutoNumber field).

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    The cause is not evident to me by just reading the code.

    Step debug. Review link at bottom of my post for debugging guidelines.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    stevegreene1 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Apr 2014
    Posts
    3
    Thanks, while I'm still not sure what was happening it seems to be resolved now. With the lines commented out, I worked on other portions of the database (specifically forms used to navigate and search the data) and after returning to uncomment the lines, I now only get one entry.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 8
    Last Post: 02-18-2014, 09:50 PM
  2. Prevent duplicate entries in linked table
    By arothacker in forum Forms
    Replies: 5
    Last Post: 02-11-2014, 11:08 PM
  3. Replies: 8
    Last Post: 01-29-2012, 12:50 PM
  4. Replies: 1
    Last Post: 12-09-2011, 07:34 AM
  5. Replies: 2
    Last Post: 04-20-2011, 06:59 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums