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

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
 
D

Douglas J. Steele

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?
 
A

Anthony

nevermind, I figured it out. I changed the variable type from "form" to
"object" so I can use it for forms AND for subforms.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top