Results 1 to 4 of 4
  1. #1
    MadTom's Avatar
    MadTom is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jun 2018
    Location
    CT and VT
    Posts
    206

    change field based on another field and increment by 1

    Been working on this all week and can't get it right! I've had so much help on this forum and have learned a lot, but still learning how to use the expression builder. Using the iif statement, but maybe another way to do what I need.
    What I'm trying to do, If Bin_CompNum = 1, Bin_Comp_ID +1 (increment by 1 if Bin_CompNum =1), Bin_Comp_ID = Comp_ID (keep Comp ID the same value if Bin_CompNum not 1). Using an Update Query. Bin_CompNum and Bin_Comp_ID are both Long Integer.

    Code:
    UPDATE tblBinsComps SET tblBinsComps.Comp_ID = IIf([tblBinsComps]![Bin_CompNum]=1,[tblBinsComps]![Comp_ID]+1,[tblBinsComps]![Comp_ID]);
    Thanks!
    Tom


  2. #2
    accesstos's Avatar
    accesstos is offline Expert
    Windows XP Access 2007
    Join Date
    Dec 2018
    Location
    Greece
    Posts
    551
    Hi Tom!

    At first, give a try to this Select query:
    Code:
    SELECT ID, Bin_CompNum, DCount("ID","tblBins","ID<=" & [ID] & " AND Bin_CompNum=1") AS Comp_ID
    FROM tblBins;
    The field ID is an autonumber field.

    I hope that helps.

    John

  3. #3
    MadTom's Avatar
    MadTom is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jun 2018
    Location
    CT and VT
    Posts
    206
    All works great, now I have to put it all together!
    My labels look great.
    John, thanks so much for all your help! you are the best!
    Tom

  4. #4
    accesstos's Avatar
    accesstos is offline Expert
    Windows XP Access 2007
    Join Date
    Dec 2018
    Location
    Greece
    Posts
    551
    You're welcome Tom!
    Happy to help.

    Wishing you all the best with your project!
    John

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

Similar Threads

  1. Increment field based on combo box
    By Squirrel1804 in forum Access
    Replies: 13
    Last Post: 02-21-2018, 11:07 PM
  2. Replies: 12
    Last Post: 06-28-2016, 11:22 PM
  3. Replies: 3
    Last Post: 02-28-2015, 06:52 PM
  4. Replies: 13
    Last Post: 05-01-2013, 09:01 AM
  5. Replies: 1
    Last Post: 02-23-2012, 11: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