Results 1 to 7 of 7
  1. #1
    westfallbp is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Mar 2021
    Posts
    26

    Increasing a number by the value of the last record


    Kind of embarrassed asking this question: I am doing a database for a friend. I have a field on a form called Item# where he enters a number for example if he enters 2 it shows 2.000 which is in the correct format. What I am trying to do on the continuous form is place a command button that he can select and it will copy and paste his Item. for example choclate bars, his distributor which are fields also and add new record, fill in the item, distributor, and add .001 to the previous record. any help would be greatly appreciated. Be nice if a macro but vba code I can do also. Thanks

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    About to go to a Teams meetings.
    Best not to have characters like # in fieldnames. Nothing wrong in having in a caption for that field.
    Most people here do not use macroes, so it will be VBA.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    westfallbp is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Mar 2021
    Posts
    26
    Wow! that really helped me out a lot..Will change Lot# to Lot Number Still have the same problem

  4. #4
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,250
    You can do it with an append query (using the current record of the continuous form) and increment the value of the item # in there Item_No:[Item#]+0.001 or you can save the values of the desired fields in variables, go to a new record and start populating the empty fields with the saved values.
    Give it a try and come back if you get stuck.
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  5. #5
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,879
    Quote Originally Posted by westfallbp View Post
    Wow! that really helped me out a lot..Will change Lot# to Lot Number Still have the same problem
    To help you out more, I wouldn't use Lot Number either. You should not have spaces or special characters in field or object names. Try LotNumber or LotNbr.
    If you do choose to use spaces be sure to enclose the entry in brackets.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  6. #6
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Quote Originally Posted by westfallbp View Post
    Kind of embarrassed asking this question: I am doing a database for a friend. I have a field on a form called Item# where he enters a number for example if he enters 2 it shows 2.000 which is in the correct format. What I am trying to do on the continuous form is place a command button that he can select and it will copy and paste his Item. for example choclate bars, his distributor which are fields also and add new record, fill in the item, distributor, and add .001 to the previous record. any help would be greatly appreciated. Be nice if a macro but vba code I can do also. Thanks
    I used to have a checkbox that indicated whether I wanted to repeat certain fields on a new record. Worked very well as I entered over 23K records reasonably easy.

    I had similar code for each control I wanted with the same values.
    Code:
    Private Sub Rank_ID_AfterUpdate()
        If Me.chkCopy Then
            Me![Rank_ID].DefaultValue = """" & Me![Rank_ID].Value & """"
        Else
            Me![Rank_ID].DefaultValue = 0
        End If
    
    
    End Sub
    I dare say it could be turned into a sub and be called from any control.
    However this was my first Access DB, so learning as I went.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  7. #7
    westfallbp is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Mar 2021
    Posts
    26
    Thanks for the input, I reas some other post and just used VBA and reset the default value + 1 and it worked

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

Similar Threads

  1. Stop Increasing Number
    By delta in forum Forms
    Replies: 2
    Last Post: 10-15-2016, 08:50 PM
  2. Replies: 7
    Last Post: 01-17-2014, 03:39 AM
  3. Replies: 7
    Last Post: 10-09-2012, 02:22 PM
  4. Forecast Query with stepwise increasing year
    By theracer06 in forum Queries
    Replies: 1
    Last Post: 08-12-2010, 06:08 PM
  5. Increasing values
    By Underworld in forum Access
    Replies: 4
    Last Post: 02-24-2010, 03:21 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