Results 1 to 11 of 11
  1. #1
    Join Date
    Nov 2004
    Location
    Saint-Constant, Qc, Can
    Posts
    4

    Unhappy Unanswered: Form/subfrom out of sync

    I do have a Main form based on a table that has an autonumber field as the primary key. I'm using this field to link to a Detail subform. The child field in the table for Detail is a long integer type exactly as the autonumber field in the Main table. The relationship is set as a one-to-many between Main and Detail tables. I did make sure that the Link Master field and Link Child field are set properly.

    Problem is, when I enter data in the subform, the linked field of the subform doesn't take the value of the main form???

    I've tried this database structure on another computer with a different version of Access with same result.

    What am I doing wrong?
    Thanks for your help.

  2. #2
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    What happens to the data you enter? What is the value of the long integer field for the Detail table? Zero? Or is it rejecting the entire record? The only thing I can think of is the Foreign Key (Long Integer in the Detail table), are you allowing duplicates? Any other code that might be resetting the Long Integer?

    Does it only happen with new Main table records? What about existing ones? It might be a timing thing where the ID is not saved right away.

  3. #3
    Join Date
    Nov 2004
    Location
    Saint-Constant, Qc, Can
    Posts
    4
    The Child field does return a zero. I did set the Main table field to NO duplicates and the Detail table field to ALLOW duplicates since I do need to have many Detail information for each Main record. I did not enter any event nor other control.

    This does apply to all Main records new or old.

  4. #4
    Join Date
    Nov 2004
    Location
    Saint-Constant, Qc, Can
    Posts
    4
    Does anybody has an idea on that problem?

    Thanks.

  5. #5
    Join Date
    Nov 2004
    Location
    Reston, VA
    Posts
    2
    I am running into the same problem. Although, when I add the subform directly to the mainform, everything works wonderfully. It is when I use a controlbutton to open the subform when I encounter the problem.

    Can anyone help with this problem? I have been stuck with this dilema for quite some time now.

    Thanks!
    Last edited by roadrunner; 11-29-04 at 15:08.

  6. #6
    Join Date
    Dec 2003
    Location
    Dallas, TX
    Posts
    1,004
    Quote Originally Posted by ish010
    Does anybody has an idea on that problem?

    Thanks.
    Hi ish010 and "Welcome to the Forum"
    It would be a very big help and will keep this thread from stretching out a mile long if you could attach a sample of your database (sensitive data removed) and Zipped down. That way someone could better see what is going on and either give you a good way to fix it, or fix it for you. Just make a Copy of your database to attach, takes just a sec. or two.

    have a nice day,
    BUD

  7. #7
    Join Date
    Nov 2004
    Location
    Reston, VA
    Posts
    2
    Quote Originally Posted by Bud
    Hi ish010 and "Welcome to the Forum"
    It would be a very big help and will keep this thread from stretching out a mile long if you could attach a sample of your database (sensitive data removed) and Zipped down. That way someone could better see what is going on and either give you a good way to fix it, or fix it for you. Just make a Copy of your database to attach, takes just a sec. or two.

    have a nice day,
    BUD
    BUD,

    I don't know what happened to ish010, but I am having a similar problem. If I include a subform to my main form the primary and foreign keys synchronize. If I create a command button to open up a form, instead of embedding it as a subform, the two keys do not sync. with each other.

    I have included a very dumbed down version, that produces the same results, for review.

    Please help! I have been faced with this dilema for quite a while now.

    Thanks,

    RoadRunner
    Attached Files Attached Files

  8. #8
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    From a brief look I'd say your form design works if you press the button, AND there is data for that parent realtionship then it is displayed

    I don't think the data model / table design is right though. The definition of the keys is all wrong. I would reccomend that where you have a foreign key (ie the child table) you use the same name or something very similar.

    There is no prime key for each table

    I don't understand why you have defined the keys the way you have, but then I stopped doing schoolwork nearly 26 years ago (well 22 if you include university), and I don't do anymore unless its for my own children

  9. #9
    Join Date
    Nov 2004
    Location
    Saint-Constant, Qc, Can
    Posts
    4

    Smile

    I'm attaching my database so you can have a look. It's an early stage database.

    Thanks for your help.
    Attached Files Attached Files

  10. #10
    Join Date
    Dec 2003
    Location
    Dallas, TX
    Posts
    1,004
    Quote Originally Posted by ish010
    I'm attaching my database so you can have a look. It's an early stage database.

    Thanks for your help.
    Hi ish010,

    Take a look at the database I created. It is basically the same as what you designed but I reworked it and saved it back in your version....i have A2K.
    First, your Relationship wasn't quite right so I fixed that to be One-To-Many.
    Not sure if it mattered but changed the ForeignKey for TAG to Required=NO.
    I took the field you had as ProjectCost and got rid of it and placed a TextBox there as it seemed you were wanting the TotalProjectCost of all the items in the DetailSection. The way you had it set was you had to have a PreDetermined ProjectCost. If so then I have made an error. What happens now is as you fill in the items in the DetailSubform, the costs are constantly Calculated in the ProjectCost TextBox now.
    Also, placed the SubTotal for line items to the right of the DetailSubform as well. Also, just for the sake of making things a bit more so, I changed TAG to TAGid, which is the PrimaryKey that ID's that table....just for the sake of how I always name things, then you will know later on what it refers to, or anyone else that maintains your d/b later on. Also, I eliminated the spaces in the FieldNames as that just takes up time to place an underscore and can be changed to whatever in the field's Label.
    Other than that, there was no magic or coding needed. Not sure but think it had to do with your Relationship not being set correctly. So take a look at it and see if it works the way you want.

    have a nice one,
    BUD
    Attached Files Attached Files

  11. #11
    Join Date
    Dec 2003
    Location
    Dallas, TX
    Posts
    1,004
    Just one quick note. It is in my opinion as with many others to create Queries to base your Forms/Reports on. It can help in easing the ordering of your data and setting of what data you want in your Form/Reports..... Somewhere later on down the line you will need a query to pull your specific data into your Forms/Reports so it's best to try using them.

    have a nice one
    BUD

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •