Object Req'd problem

kirkm

Registered User.
Local time
Tomorrow, 04:28
Joined
Oct 30, 2008
Messages
1,257
One thing I've never understood about Access is how it addresses some things.

In the immediate window I want to see the forms Record Source. It's name is "frmMain"

I type ? frmMain.recordsource
Run-time error '424': Object required

Then ? Form_frmMain.recordsource
Run-time error '424': Object required

Eventually I find this works
? Forms![frmMain].recordsource

But why? What Object can it possibly want? I'm sure the first two do work under some circumstances.
 
it belongs to [Forms] Object, therefore you need to qualify it.
 
Then ? Form_frmMain.recordsource
Run-time error '424': Object required
That one kinda surprises me. despite all the different things that you see recommended from various people, virtually the only thing I use in code is the form underscore and then the name of the form... this always works as long as the hasmodule property of the form is set to true, and eliminates a lot of having to 'think' about scope. Are you sure you didn't have a space after the question mark?

But the form probably has to be displayed too.
 
Last edited:
I'll try and remember it belongs to the Forms object... but I'll prob still make the mistake.
Issac I tried with and without space, it was the same. The Form was being shown but it isn't modal. I did ALT F-11 to get to the debug window.
So where does Form_frmMain.recordsource syntax work ? Only in code ?
 
Here is a reference on how to reference a form:


Remember that for some time now, the collection names have changed slightly. There is Forms (all open forms) and there is AllForms (which even includes closed forms.)

Here is another reference on how to reference a form. This comes from FMS, Inc, which is often a good source of info.

 
Thanks.,.. found another way that works
? Forms("frmMain").RecordSource

But nothing using "AllForms" did.
 
Usually, when dealing with the AllForms collection, you step through (enumerate) the members of that collection with a For Each form in AllForms or something like that. But before you can use anything you have found there, you have to test the .IsLoaded property. Otherwise, there is no open instance of that form.
 
It's a little hard to figure ... I tried
? Forms("frmMain").isloaded
And got
Run-time error '2465':
Application-defined or object-defined error
 

Users who are viewing this thread

Back
Top Bottom