View Full Version : Subforms and VBA


ALF3911
06-28-2001, 01:38 PM
I am slowly learning VBA code on my own and really like it. Unfortunately, I sometimes get stuck on things that I think are easy. I am trying to access a field from an open subform and copy it to the form that just loaded. I am trying the following:

Private Sub Form_Load()
TechID = Forms![frmFirstPage]![frmPoweredBy].Form!PowerID
End Sub

However, I keep getting a message stating the field frmPoweredBy is not found.

I am probably missing something easy, but if someone can help I would appreciate it.

Robert Dunstan
06-29-2001, 06:11 AM
Hi,

Try this

TechID.Value = Forms![frmFirstPage]![frmPoweredBy].Form!PowerID.Value

ALF3911
06-29-2001, 07:10 AM
Ok, that gives me the same error. I did not mention before that the subform lies in a tab control on the main form (I did not think it was important). I am beginning to think that might make a difference. Do I need to call the tab control page first? If so, how can I do this?

Thanks

KevinM
06-29-2001, 07:18 AM
No, you shouldn't need to reference the tab control.

Have you tried...

TechID = Forms![frmFirstPage]![frmPoweredBy]![PowerID]

Without the '.Form'.

Also, try it on the onOpen event instead of the OnLoad event.

hth

ALF3911
06-29-2001, 01:28 PM
Thanks for the help. I never did get it to work, but I managed to work around it.