My Assistant
![]() ![]() |
|
|
Feb 3 2006, 10:46 AM
Post
#1
|
|
|
New Member Posts: 1 |
Hello. I'm going crazy here on what I would think would be the easiest thing.
First, my table structure. I have a table(Master) with one field which is a p.k. - we'll call it masterID. I have another table(Detail) that holds details for this masterID...primary key is a combination of two fields -- masterID, and an autonumber column - DetID. So Master has a 1-many relationship to Detail. So now i have a form with a subform. Main form has only one text box, bound to the Master.masterID column. The subform displays detail records that contain the current value (masterID) of the main form text box. Classic 1-many form-subform scenario. This is driving me crazy though. I cannot seem to add records in the subform. I can edit, but not add. I get the good old "You can't assign a value to this object" *The object may be a control on a read only form (its not) *The object may be on a form open in Design view (its not) * The value may be too large for this field (its definitly not) I've got the allowinsert, allowupdate, allowdelete all set to yes. Another thing I should note that in my subform, I automatically fill in the in masterID column or field by referring to the main forms textbox value. One thing I notice is that I can, after this error message pops up, continue with the insert. The insert does work, but it does not retain the masterID value, and instead defaults to 0 in the Details table. I've gone through a few times and recreated the form, used combo boxes, etc...with the same problem. I also ran a compact & repair. I would think this should be simple, but I'm losing it here. Any advice would be appreciated. I've searched through the forums and I haven't found any solution that seems to work. Thanks. |
|
|
|
Feb 3 2006, 10:59 AM
Post
#2
|
|
|
Utter A-fishin'-ado Posts: 17,723 From: Cincinnati, Ohio, USA . . . ><((((°> |
Welcome to UA!
The scenario you describe is not the typical Master-Detail setup. Your Detail table should have DetailID set to be the PK by itself, not in combination with the MasterID. MasterID in the Details table should be a LongInteger field. You should enforce referential integrity between the two MasterID's in the relationship window. Then, on the subform control, just specify MasterID as both the master and child link. There should be no need to manually populate the MasterID in the Detail table. |
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 23rd May 2013 - 02:00 PM |