Results 1 to 5 of 5
  1. #1
    RamiMohaisen is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2012
    Posts
    7

    Question Auto create records

    Hello all,



    Need some help from you experts. This seems simple to me but I am a super rookie and have no idea how to accomplish it.

    I have one very simple table with three fields:

    RequisitionNumber
    LineNumber
    OrderNumber

    When I need to enter a new requisition, say with 10 line items on it, I have to enter 10 separate records which is annoying. Especially the fact that I always make a typo. I have to enter "requisition number" 10 times and 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 and so on for each line number.

    I would like a MAGICAL BUTTON on a form or code I can run straight from the table to do the following:

    When I want to add a new requisition is asks for requisition number. Lets say i type "201294843".
    Then it asks for the number of line items on that requisition. Say i type "7".

    I want it to automatically go and create the 7 records for me in my table. like shown below:

    Requisition Number Line Number Order Number
    201294843 1
    201294843 2
    201294843 3
    201294843 4
    201294843 5
    201294843 6
    201294843 7

  2. #2
    RamiMohaisen is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2012
    Posts
    7
    Ok,

    I think ive made it one step closer. I created an append query with the SQL as follows:

    INSERT INTO PRAllocation ( PRNo, LineNo )
    VALUES ([forms]![Form1]![txtPRNo], [forms]![Form1]![txtLineNo]);


    Now this will create one record in the table with the PR number and the Last line number. All i need is some way to keep re-running this same query but with lineNo-1 each time until it reaches 1.

  3. #3
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,536
    Why not create a form and a subform. The form will hold the Req Number and the subform will hold the details. Look at this tutorial.

    http://www.datapigtechnologies.com/f...subforms1.html

  4. #4
    RamiMohaisen is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2012
    Posts
    7
    Quote Originally Posted by alansidman View Post
    Why not create a form and a subform. The form will hold the Req Number and the subform will hold the details. Look at this tutorial.

    http://www.datapigtechnologies.com/f...subforms1.html

    OK, but

    How do I make the subform populate. If i get a req with 100 lines i have to sit there in the subform and type 1 ENTER, 2 ENTER 100 times.

  5. #5
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    Maybe use something like this in the SubForm's Before Update event to auto populate the Line Number field
    Code:
    If Nz(Me.[Line Number], 0) = 0 Then
      Me.[Line Number] = DMax("[Line Number]", "[TblOfLineNums]", "[Requisition Number]= " & Me.[Requisition Number]) + 1
    End If
    Change TblOfLineNumsto the name of the table that has the Line Number field.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

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

Similar Threads

  1. Replies: 3
    Last Post: 04-07-2012, 09:01 AM
  2. Replies: 12
    Last Post: 08-30-2011, 03:36 PM
  3. Replies: 3
    Last Post: 07-10-2011, 05:37 AM
  4. Auto Record create across tables
    By b123 in forum Database Design
    Replies: 15
    Last Post: 10-02-2010, 01:36 AM
  5. Auto-Create a Table
    By Mxcsquared in forum Forms
    Replies: 3
    Last Post: 01-28-2006, 11:36 PM

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