PDA

View Full Version : subform refrencing VBA


jim_roberts1
12-05-2002, 05:49 PM
I'm having trouble referencing a second subform in VBA in an AccessXP database. We are trying to create a subform within a subform and then code a change in the AllowEdits method.

'these two work:
forms!frmMaster.Form!frmSub1.Form.AllowEdits = True
forms!frmMaster.Form!frmSub1.Form!frmSub2.Form.All owEdits = True

'This third one doesn't work:
forms!frmMaster.Form!frmCar.Form!frmArrival.Form!f rmJob.Form.AllowEdits = True

Please note there is not a line change in the actual code.

Can you all help me get this right? thanks.

Paul Komski
12-05-2002, 10:06 PM
"The third line" implies a third nested subform which shouldn't have been allowed to be created in the first place. Two is the maximum I believe.

You appear to be referencing frmJob as a subform of frmArrival as a subform of frmCar as a subform of frmMaster. That's three nested inside frmMaster! Or is the actual form structure different from this??

jim_roberts1
12-06-2002, 11:06 AM
You're reading that correctly. It's a third nested subform.

frmMaster
frmCar
frmArrival
frmJob

So that's not allowed? It is working if I changed the properties manually, it works. The only problem I have is referencing the subform in VBA. Is this a limitation of VBA?

Thanks for your reply.

jim_roberts1
12-06-2002, 06:02 PM
I've done a bit of research and found this snippit from Microsoft:

"A main form can have any number of subforms if you place each subform on the main form. You can also nest up to seven levels of subforms. This means you can have a subform within a main form, and you can have another subform within that subform, and so on. For example, you could have a main form that displays customers, a subform that displays orders, and another subform that displays order details. However, a form will not display subforms in PivotTable or PivotChart view."

Paul Komski
12-06-2002, 11:22 PM
Sorry JR1 - I just went into Access97 and it wouldn't let me nest more than two. Access2000 is apparently 9 or 10 and you say AccessXP is infinite!! LOL :D

You could try:-
Forms![frmMaster]![frmCar]![frmArrival]![frmJob].Form.AllowEdits = True

.. since the syntax:-
Forms![frmMaster]![frmCar]![frmArrival].Form.AllowEdits = True
.. does work for two nested subforms; in 97 anyways.

I can't try it out until I install OfficeXP, but I'm waiting for a new pc to install it on due to the activation stuff.