Results 1 to 4 of 4
  1. #1
    tagteam is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    494

    use update query to create numerical range

    I am working on an inventory input system. I would like to be able to add 10 inventory parts at one time since they all have the same basic data. However, for each set I need to serialize them so I can pull them out later in a sequence. The serial will be a simple number scheme from 1-10 for example.

    i would like fill out a form, then click a button and have it add the data the specified number of times (from a unbound field) and then add an incremental number to each line item in a serial field.

    So after clicking the button I would have something like this

    part descp serial
    valve basic valve 1
    valve basic valve 2
    valve basic valve 3

    Creating the insert query is easy but I am not sure how to get it to run 10 times for example ( I could click the button 10 times, but i want to make sure the serial increments by 1)

    Thanks for any help

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    I'd use a For/Next loop. The counter variable can be used for your serial field.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    tagteam is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    494
    Thank you for your reply. The problem is I am not very good with VBA so creating a For/Next loop may be beyond my ability. I see there are if statement abilities in the macro creator but I don't know if it can create loops.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    Not even going to try?

    Code:
      Dim intPartCount             As Integer
    
      For intPartCount = 1 To Me.txtPartQuant  'textbox with the number required
    
        'insert using AddNew method of recordset or executing SQL, either one using intPartCount for the serial number
    
      Next intPartCount
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 12
    Last Post: 05-02-2017, 07:39 PM
  2. Replies: 4
    Last Post: 11-14-2015, 03:23 AM
  3. Create an update query
    By Bobwords in forum Queries
    Replies: 3
    Last Post: 08-12-2014, 10:32 AM
  4. Replies: 5
    Last Post: 06-13-2012, 07:43 PM
  5. Query Numerical and Text
    By Athyne in forum Queries
    Replies: 1
    Last Post: 01-14-2012, 12:07 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