Results 1 to 9 of 9
  1. #1
    sgp667 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2012
    Posts
    17

    From that makes Multiple records

    Hi guys my name is Thomas and I am pretty new to access, and this forum as well. I am not sure if this question belongs in this section of the forum but, I was asked to make database for managing company's supplies. For this data base I need a form that will produce multiple entries on two tables(trust me if I would be the only person using this database I would make two forms for this, but people that will be involved are not big computer fans so I need to simplify things for them).

    So the form I am making is for inputting Invoice items where user will have to just input item name, item type and their quantities. The result of most entries is simply a new record in "InviceItems" table. However when user inputs specific item type( in this case "Machine"), then I need a new record to appear on another table as well("MachineList"). ALSO if the quantity of Machines inputted by user should correspond to amount of new entries made in "MachineList" table.



    I should note that i am not familiar with Macros, or VBA but if anyone can provide me with specific script I would be happy to take it.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    This sounds like duplication of data, which is counter to principle of relational database to not duplicate data. Want to provide db for analysis? Follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    sgp667 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2012
    Posts
    17
    I'm sorry but I'm unable to shrink the db under 1.01mb (uploader reuquires me to have 500kb at most).

    So let me explain one this a little bit better.

    Currently I have three tables(fields in these tables are in brackets), and one Form:

    Invoice Items [ItemName, ItemType, Quantity, Price, Invoice#]
    -list of items that appear on our Invoices
    -this is where every entry on my Invoice Form appears
    -this is used for queries that will count our purchases

    Cleaning Assets List [ItemName, ItemType]
    -this is just a list items used by company
    -this is used to limit items that user can put in Invoice Items Form

    Machine List [MachineID, ItemName, Invoice#]
    -it is a list of individual machines rather than Machine types we use( Machine Types can be found in "Cleaning Assets List"
    -when a new machine(s) appear on Invoice a new entry has to be made here( or more depending on Quantity inputted in row with an [ItemType] "Machine")

    Invoice Form
    -this is the form where user will put items that appear on our invoices
    -this is also the form that needs to make multiple entries in MachineList


    I guess I should stress that "Cleaning Assets List" is just a list of items company allows us to buy( thus have on invoice), and "Machine List" is more detailed because it actually lists machines one by one( to keep track of their status exp. Broken, Available, InRepair ect.).

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Still don't follow the setup.

    Per my instructions, zip the file, 2mb allowed.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    sgp667 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2012
    Posts
    17
    Ok I found my mistake from yesterday
    Database sample.zip

    This File has only the components in the database that i stated before.

    Thanks for the help

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Think understand now. You buy 5 items (MM Vacuum) on invoice 111. You want a record in Machine Archive for each of the 5 items to track equipment asset. Need to add field for 'Status'?

    If you want code to automate adding the 5 records, will involve INSERT sql action. The code itself is not that difficult. What gets tricky is figuring out what event to put the code in and have measures to make sure the items are not posted to the table multiple times.

    Simple code example:

    Dim i As Integer
    If Me!ItemType = "Machine" Then
    For i = 1 to Me!Quantity
    CurrentDB.Execute "INSERT INTO [Machine Archive]([Item Name], Invoice) VALUES '" & Me![Item Name] & "', '" & Me![Invoice#] & "'")
    Next
    End If

    Invoice# in InvoiceItems is number type (should it be autonumber?) but the Invoice field in MachineArchive is text. These fields should be same datatype if you want to be able join in query.

    Advise not to use special characters and spaces in names nor reserved words as names. If you do, must in enclose in [].
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    sgp667 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2012
    Posts
    17
    Ok this code does look promising, I was doing a little bit of research as to where can I paste it, and so far all I got is Query.
    I guess if it possible I would execute this when pressing save button on my form.

    You are right about the invoice field it was just an error, also the Machines will have status, but my plan is to have a "Status Event" table so that I would determine each machine's status by most recent status event.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Yes, could put code in button 'Save', however, if 'Save' is clicked again another set of records will be saved. Be careful with offering this kind of feature to users.

    Don't understand 'and so far all I got is Query'.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    sgp667 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2012
    Posts
    17
    I finally embedded the code it works great.

    Thanks

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

Similar Threads

  1. Accde Creation makes Requery errors etc
    By big-div in forum Access
    Replies: 0
    Last Post: 06-04-2012, 03:58 AM
  2. What makes form 'design save' before open?
    By bhammer in forum Forms
    Replies: 2
    Last Post: 04-23-2012, 03:08 PM
  3. Replies: 3
    Last Post: 01-05-2012, 12:04 PM
  4. Adding column as INTEGER makes it a long integer?
    By luckycharms in forum Programming
    Replies: 2
    Last Post: 10-20-2010, 02:47 PM
  5. Replies: 1
    Last Post: 12-10-2009, 08:41 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