Results 1 to 6 of 6
  1. #1
    1gixxer is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2013
    Posts
    4

    Add multiple records to same table from subform

    Ok where to begin,

    I’ve only started using Access 2010 since the beginning of January and have google’d almost every problem to date. This forum has been a gold mine of help but after days of searching I cannot find a solution for this problem .

    So I’m hoping you guys can help.

    Some background

    My db is used to show the status of material through a manufacturing process.
    We start with one slab of material which gets cut up in to many parts.

    The db works so far however I’ve come to the conclusion that the date was not normalized correctly. So I’ve created the following tables to fix this.

    I have two tables the first of which holds data on the slab we start with and the second shows the status of the parts it has been cut up into.


    Table 1 has the following fields

    Cast Number
    P/O
    UST Status


    UST Comment

    Table 2 has the following fields

    Cast Number
    Blade ID (which will be 1 to 32)
    Status
    Comment

    I would like table one to be displayed on a form with all fields. Have table two as a subform on the main form. But here is where I get lost!

    I need the subform to show 32 text boxes to represent each part. Have each box assigned a default blade ID (1 to 32). Then depending which of the 32 text boxes get used to update those multiple records within Table 2.

    I did have 32 status fields for every part but realised that meany were left null. Am I even going down the right road here?

    I'm using, Access 2010 with Win 7


    I hope that makes sense... I'd appreciate any and all help please.

  2. #2
    alcapps is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Jan 2012
    Posts
    292
    Cast number
    bladeid

    Event after insert

    dim db as database
    set db = currentdb()
    for i = 1 to 32
    Db.execute "INSERT INTO Cast number " _ & "(Cast number,Bladeid) VALUES " _
    & "(" & me.castnumber & "," & i & ");", dbfailonerror


    next

    me.subformname.requery

    you can tweak this and it should do what your trying to do.

    Answered. On an iPad

    hope this helps

  3. #3
    1gixxer is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2013
    Posts
    4
    Trent dB.zip

    I’ve attached a mock db which should help explain what I’m trying to achieve


    alcapps - Thank you, Ill give your script a whirll and let you know how i get on.

  4. #4
    1gixxer is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2013
    Posts
    4
    Ok, I’m a little unsure what object to apply the "Event after insert" code to.

    I have to admit my knowledge of VBA is not the best.

    I had imagined that each text box would require an after update or before update script that first defines its associated blade ID. Then write that ID to the next record within the BladesStatus Table along with the date entered within the text box.

    Thank you so much for any help.

  5. #5
    alcapps is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Jan 2012
    Posts
    292
    Trent dB.zip

    ok I had to change things around. You had a few things out of place. Here is an example of what you can do.

    try not to add blanks to the field names it makes code and querys get cluttered up trying to handle the special characters.

  6. #6
    1gixxer is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2013
    Posts
    4
    alcapps...... you is da bomb!

    Thank you sooooo much!!!!

    Below is the code used in case it helps any one else.

    Private Sub Form_AfterInsert()
    Dim db As Database
    Set db = CurrentDb()
    For i = 1 To 32
    db.Execute "INSERT INTO BladeStatus " & "([Castnumber],[Bladeid]) VALUES " & "('" & Me.[Cast Number] & "'," & i & ");", dbFailOnError
    Next
    Me.frmBladeStatus.Form.RecordSource = "SELECT bladestatus.castnumber, bladestatus.bladeid, bladestatus.Status, bladestatus.Comment FROM bladestatus where CastNumber ='" & Me.[Cast Number] & "'"
    Me.frmBladeStatus.Requery
    End Sub

    Private Sub Form_Current()
    Me.frmBladeStatus.Form.RecordSource = "SELECT bladestatus.castnumber, bladestatus.bladeid, bladestatus.Status, bladestatus.Comment FROM bladestatus where CastNumber ='" & Me.[Cast Number] & "'"
    Me.frmBladeStatus.Requery
    End Sub

    Thank you again alcapps.

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

Similar Threads

  1. Multiple Records from a Form/Subform
    By Schowti in forum Access
    Replies: 39
    Last Post: 06-18-2012, 01:32 PM
  2. Multiple records in a subform
    By rashima in forum Forms
    Replies: 4
    Last Post: 05-15-2012, 09:50 PM
  3. Multiple Subform records
    By Lupson2011 in forum Access
    Replies: 2
    Last Post: 08-24-2011, 08:49 AM
  4. Prepopulate subform with multiple records
    By Erik Feenstra in forum Forms
    Replies: 1
    Last Post: 05-02-2011, 07:28 AM
  5. Adding multiple records in subform
    By randolphoralph in forum Programming
    Replies: 1
    Last Post: 05-12-2010, 09:42 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