Results 1 to 8 of 8
  1. #1
    Fredrik831 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2012
    Location
    Sweden
    Posts
    14

    Help with synchronising a subform with a masterform

    Hello,



    I'm building a DB for a company and I have run into a bit of trouble and are now hoping for someone better than me to give me some advice

    I'm using a form to create new posts to three linked tables. I'm using a masterform with two subform, where each subform is handling one table each. As long as I'm entering data in the masterform FIRST, then everything is perfect. My masterform is synchronising with the subforms with an ID that is autogenerated with each post.

    However, if I should insert data in one of the subforms FIRST, then the ID isn't generated, and the forms and tables will not be synchronised.

    I hope you understand my problem. Is there some way to force the masterform to generate a ID? Any ideas?

    Thanx in advance!

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,743
    It seems you may have a logic issue with your process, in my view. Typically form/subform set up deals with tables that have a 1:Many relationship. Samples of this sort of relationship are
    A Person has many Hobbies; An Order has Many OrderItems; A Family has Many Children....
    So, by analogy,
    By attempting to add an OrderItem before you have an Order seems to be your issue.

    New Child Robert belongs to Family?? Have to identify the Family and then associate the Child with the family.

    I may have misunderstood your issue.

  3. #3
    Fredrik831 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2012
    Location
    Sweden
    Posts
    14
    You seem to understand my issue My form/subforms are dealing with tables that have a 1:M relationship. The problem occurs when I'm trying to create, for example, an Orderitem Before I have created an Order. This is a problem because in reality you might want to enter some of the details in the Orderitem before some of the details (if any) in the Order. I would like to automatically create an Order when I'm creating the Orderitem.

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,743
    Think of a slightly different analogy.
    Suppose you want to withdraw money from your bank account --- you have to have a bank account before you can withdraw funds.

    In your case, if you somehow have something (OrderItem) that you are "creating", then create the Order and then the OrderItem.

  5. #5
    Fredrik831 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2012
    Location
    Sweden
    Posts
    14
    Quote Originally Posted by orange View Post
    Think of a slightly different analogy.
    Suppose you want to withdraw money from your bank account --- you have to have a bank account before you can withdraw funds.

    In your case, if you somehow have something (OrderItem) that you are "creating", then create the Order and then the OrderItem.
    That is the case now, I create the Order first and then the OrderItem, and it works splendid. However, in my case it would be prefered if you could enter the details in the OrderItem first (because the data in the OrderItem is mandatory, which the data in the Order is not, more than the autogenerated ID).

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,743
    It's possible you have a design issue. It it doesn't make sense (seem logical) to have an Order before you have an OrderItem, then maybe you should rethink your issue/business. Could be you have to stand back and take a different view.

    Perhaps you could describe WHAT your business is and WHAT exactly your forms, subforms represent.

  7. #7
    Fredrik831 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2012
    Location
    Sweden
    Posts
    14
    Quote Originally Posted by orange View Post
    It's possible you have a design issue. It it doesn't make sense (seem logical) to have an Order before you have an OrderItem, then maybe you should rethink your issue/business. Could be you have to stand back and take a different view.

    Perhaps you could describe WHAT your business is and WHAT exactly your forms, subforms represent.
    Okay, I will try The business is a small factory, and I'm creating a DB to keep track of some tools (fixtures, http://en.wikipedia.org/wiki/Fixture_(tool)) that are used in the processing of articles. However, each tool can be used for many articles (1:M). Because of the 1:M relationship I have two tables, Tools and Articles. The Tools table have an autogenerated ID-key (ToolID) and some non-mandatory information about the tool. The Article table only consists of ArticleID (mandatory) and ToolID. Theoretically, a user might not have any information about the tool more than the ArticleID (which is written physically on each tool), therefore it would be great if the user can enter the ArticleID BEFORE any other information about the tool.

  8. #8
    Fredrik831 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2012
    Location
    Sweden
    Posts
    14
    I managed to solve this one myself

    Instead of using forms, I used VBA code to open the necessary form, export some of the values from a specific control to another control in the new form, and then close the form.

    Here's the code, if someone else is struggling with the same sort of problem:
    Private Sub commandbutton_Click()
    RunCommand acCmdSaveRecord
    DoCmd.OpenForm "form1"
    Forms("form1").Textbox1.Value = id1.Value
    Forms("form1").Textbox2.Value = id2.Value
    DoCmd.Close acForm, "form1"

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

Similar Threads

  1. Replies: 4
    Last Post: 10-08-2012, 05:33 PM
  2. Replies: 6
    Last Post: 05-05-2012, 08:43 AM
  3. Replies: 4
    Last Post: 03-30-2012, 01:47 AM
  4. Synchronising tables?
    By Juicejam in forum Access
    Replies: 0
    Last Post: 03-05-2012, 09:07 PM
  5. Synchronising tables?
    By Juicejam in forum Database Design
    Replies: 0
    Last Post: 02-09-2012, 09:30 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