Results 1 to 9 of 9
  1. #1
    digitalbalu is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Mar 2012
    Location
    India
    Posts
    14

    How to insert Mastertable value into child table?

    I am having Two tables



    Master: RyotNo (Primary Key), CategoryNo,RyotName, Address, City, BankAccNo

    Child: RyotNo(Foreign Key), TDate(PrimaryKey), LorryNo(PrimaryKey), Weight(PrimaryKey), CategoryNo(PrimaryKey)

    If I insert a RyotNo in Child table, its categoryID must also be stored in Child table CategoryNo.
    Plz help me. Thanks in advance.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Why do you need the CategoryNo in child table? How can it be a primary key in the child? It can be retrieved by linking the tables on the RyotNo pk/fk fields.
    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
    digitalbalu is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Mar 2012
    Location
    India
    Posts
    14
    Dear June7, I am doing a sugarcane Agency project assigned by X.
    At very first X told that he want to enter Load details from multiple customers, he strictly told Date, LorryNo, Weight should not come again for any customers.
    I designed,
    Ryot(Customers) Table as RyotNo, RyotName, Address, City, AccNo
    LoadDetails Table as RyotNo(FKey), TDate(PKey), LorryNo(PKey), Weight(PKey), Rate, Amount(Weight*Rate), AdvancePaid, Nett(Amount-AdvancePaid)
    and its working fine for me. I delivered the DB too.

    But today X told that he manages 3 types of customers in single load,
    1. Drivers (The lorry drivers of that load)
    2. Farmers ( They are the owners of the Sugarcane)
    3. Labours (They are harvesting the sugarcane in that field)
    Now the X's condition becomes Date, LorryNo, Weight for the Particular group of customers should not come again.
    ie.. If a driver gives 6/4/2012, TN32AR5868, 18.580 then it should not re entered by any drivers, but can be entered by Farmers & Labours

    This is the reason Why I have Date, LorryNo, Weight, CategoryNo as primary in LoadDetails(Child). I want use the single table to store all these. This is the exact reason for that. If any corrections in the DB, please suggest me. Thanks in advance...

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Oh, I see now, compound unique ID.

    Is data entry in forms or directly on table (I hope forms are used)?

    Set value of the child CategoryNo based on value of master CategoryNo. The trick is figuring out what event to trigger this. Then need to handle situation if the entries are duplicates of existing record. Perhaps a 'Save Record' button for the child form.
    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
    digitalbalu is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Mar 2012
    Location
    India
    Posts
    14
    Yes. I am using forms for data entry. I give u the old db here. Please analyze it for current modification. X always require report in the specified format. I use LorryNo's default value is current time format in hhmmss bcoz, the customers sometimes get only payment from X. Due to the db size is >= 500 KB. I upload it in 4Shared. thanks in advance..

    SugarCane.accdb

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    That site wants me to download software before I can download the file. Don't want to download software. Box.com does not do that.

    Try attaching to post. Follow instructions at bottom of my post. Up to 2mb zip 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.

  7. #7
    digitalbalu is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Mar 2012
    Location
    India
    Posts
    14
    Thanks for the info. The db is now in http://www.box.com/s/bd9e51871ffb7435057d

  8. #8
    digitalbalu is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Mar 2012
    Location
    India
    Posts
    14
    The db is ....
    SugarCane.zip

  9. #9
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Need field in Transactions for the Category. Do you want it to be a number and save 1, 2, 3 or text and save Farmer, Labor, Driver? Include it as part of the compound PK. Now if user tries to enter record that duplicates this compound key, Access will popup error message and record will not save.

    The two tables have a relationship defined in the Relationships builder, hence the + on the parent table.

    Field name VechileNo is misspelled.
    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.

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

Similar Threads

  1. Replies: 5
    Last Post: 03-23-2012, 11:40 AM
  2. Replies: 2
    Last Post: 12-31-2011, 07:03 AM
  3. Replies: 2
    Last Post: 12-20-2011, 07:33 AM
  4. Replies: 10
    Last Post: 01-17-2011, 10:47 PM
  5. Pulling most recent data from child table
    By davidv43 in forum Access
    Replies: 0
    Last Post: 02-07-2009, 11:36 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