Results 1 to 6 of 6
  1. #1
    janmack79 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2016
    Posts
    30

    Update the First Record in a Table

    Hi I have duplicate records and I am trying to figure what I would enter for the criteria in and Update query. If you look at my screen print I want to enter a number "1" in the field Opp Count for the first occurrence of an Opportunity Number in that same table.



    Click image for larger version. 

Name:	Capture.jpg 
Views:	14 
Size:	96.8 KB 
ID:	29781

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,441
    Run a query

    SELECT [OPPORTUNITY NUMBER], MIN([DATE CREATED])
    FROM [LENGTH TO CLOSE DETAIL]
    GROUP BY [OPPORTUNITY NUMBER]

    link this query back to your LENGTH TO CLOSE DETAIL on BOTH the opportunity number AND the created date. This will identify which records need to be updated. Depending on how you progress from there you may be able to run an update query or manually update your table.

    Some things to keep in mind
    1. Don't use spaces in your field/table names
    2. Don't use special characters other than underscores (_) in your object/field names (i.e. name your table Length_to_Close_Detail rather than including spaces)
    3. Read rules on data normalization

  3. #3
    janmack79 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2016
    Posts
    30
    The Date Created is not unique that is duplicated as well, there is more than one Product on some the opportunities so Min of Date created would not be helpful I believe because it would still populate a 1 for all the records?

  4. #4
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,441
    then how are you going to identify the 'first' record for each opportunity number?

  5. #5
    janmack79 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2016
    Posts
    30
    I guess that is my question, are you not able to just identify the first occurrence of a record based on the first time it appears to update another field? Or is not that simple

  6. #6
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,441
    If you are using an autonumber primary key, you can identify the first record to get into your table
    if the records were entered sequentially you could go based on the minimum value in that autonumber table.

    The best method though would be to sequence them as the data enters the table rather than try to do it after the fact.

    If you don't have an autonumber primary key it doesn't really matter which was the 'first' record if you have five on the first day what does it matter which one you pick as 'first'

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

Similar Threads

  1. Replies: 6
    Last Post: 06-26-2017, 07:42 PM
  2. Replies: 4
    Last Post: 02-18-2015, 11:28 AM
  3. Update Table after Record Update with Form
    By speciman_A in forum Forms
    Replies: 25
    Last Post: 10-31-2014, 01:00 PM
  4. Replies: 4
    Last Post: 06-27-2014, 04:34 PM
  5. Replies: 3
    Last Post: 05-23-2012, 07:48 AM

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