How do I set a subform variable to the source object of a subform control?

  • Thread starter Thread starter Anthony
  • Start date Start date
A

Anthony

I'm trying to do something like this:

--
Dim sf as subform

set sf = forms(mySubFormControl.SourceObject)
--

But I keep getting this error:

"Microsoft Access can't find the form '(my form name)' referred to in a
macro expression or Visual Basic code.

please help

Anthony
 
When a form is being used as a subform, it doesn't actually exist in the
Forms collection.

Not only that, but when you declare an object as a subform, you're actually
declaring the control that holds the form that's being used as a subform:
you don't believe you can assign a form to a subform control.

What exactly are you trying to accomplish?
 
nevermind, I figured it out. I changed the variable type from "form" to
"object" so I can use it for forms AND for subforms.
 
Back
Top