View Full Version : sub-subforms


K.Smith
07-23-2001, 09:37 PM
First off, I'm cluelessly lost and I don't know what the heck I'm doing. That said...

I have two tables that have a 1:N relationship with each other and both have 1:N with a third table. For simplicity (for the user), I wanted to input data into all three tables from the same form. The method I chose was a main form with a subform that has an embedded subform (the third table). With some minor macro gymnastics, it runs pretty smoothly the first time. The problem is (and this is where it gets confusing) when the user is done with the last field of the sub-subform, focus doesn't break from that subform. I can "SelectObject" my way back to the main form and that works great, but I can't go to the first field of the subform--with GoToControl or any other method I've read about. I even used SelectObject to get to the main form and tried to GoToControl to the subform, but it gave an error about the subform not existing. In a nutshell, when I get into the sub-subform, I can't seem to get focus back to the subform.

Confusing? Imagine a buck-private newbie trying to figure this out. I feel like I'm stuck in quicksand: the more I fight it, the deeper I sink.

Thanks for any comments or suggestions.
Kevin

Steven Deetz
08-01-2001, 09:16 AM
I had the same problem with an app and could not find any answers on how to move to the subform. I finally gave up and reworked the design of the forms so there was a form, a sub-form, and a linked form taking the place of the sub-sub form.

The Before Insert Property of the linked form is where you add code to fill the foreign key. If you want the linked form's foreign key to be filled with the subform's ID remember to use the following syntax:

Me![Foreign Key]= Forms![Main Form]![Sub Form].Form![subformID]

To fill it with the main form's ID you would use the following syntax:

Me![Foreign Key]= Forms![Main Form]![Main FormID]

I have shied away from sub-subforms as the size of a database grows. If I understand Access correctly it will refresh the sub-subform first, the subform second, and the main form last when you move from record to record. It doesn't take many records (2 to 3 thousand) and things really slow down.

Hope this is of some help!

K.Smith
08-01-2001, 10:39 AM
Thanks for the info. I've reworked it to handle it a different way.

Kevin