Me returning different results to Forms("MyName") (1 Viewer)

andrewmrichards

Registered User.
Local time
Today, 15:55
Joined
Mar 15, 2012
Messages
18
Hi all,

I hope you can help with this - it's been driving me up the wall today, but I've never come across it as a problem before.

I have forms set up as follows:

frmFrame - this holds a Subform control called ChildForm.
ChildForm has as its SourceObject a form called frmTitleOuter

frmTitleOuter has a number of OptionButton controls, and also a Subform control, once again called ChildForm.

The ChildForm control of frmTitleOuter can contain various forms to show different kinds of information.

I've attached a screenshot of this, to hopefully help you to visualise it.

Depending on which form is showing in the frmTitleOuter's ChildForm control, some of the OptionButtons should be made visible and others hidden.

So, here's my problem.

I have code on frmTitleOuter which looks like this:

Code:
If Me.ChildForm.SourceObject = "fsubFormatTracks" Then
'    hides some and shows other buttons
This has always worked. But now, the SourceObject property is returning an empty string.

However, if I re-write the code to say
Code:
If Forms("frmFrame").ChildForm.Form.ChildForm.SourceObject="fsubFormatTracks" Then
' etc
then I get returned the name of the child form as expected.

I'm having the same issue with another bit of code, which should switch the subform...

Code:
Me.ChildForm.SourceObject="fsubTitleFormats"
is now refusing to work, but

Code:
Forms("frmFrame").ChildForm.Form.ChildForm.SourceObject="fsubTitleFormats"
works fine.

Might it make a difference that the code is originally being called from the subform of frmTitleOuter? The code itself resides in frmTitleOuter, but can be called from various events.

It's worked absolutely fine for years, but I'm having to re-develop bits as part of a migration to SQL Server, and I've not actually changed any of this code, which is why I'm confused as to why it's popped up as an issue now! If you can help, I'll be eternally grateful.

Many thanks
Andrew
 

Attachments

  • Database screenshot.jpg
    Database screenshot.jpg
    98.1 KB · Views: 117

VilaRestal

';drop database master;--
Local time
Today, 15:55
Joined
Jun 8, 2011
Messages
1,046
Questions that spring to mind:

Do
If Me.Parent.ChildForm.Form.ChildForm.SourceObject="fsubFormatTracks" Then
and
Me.Parent.ChildForm.Form.ChildForm.SourceObject="fsubTitleFormats"
work?

Is there On Error Resume Next in the code (before)? Have you tried switching off and seeing what error it produces (or at least debug.print err.description after those lines)?

Have you tried a fresh database (a new accdb or whatever, set its references in VBA and then import all objects from your existing database)? It could be some sort of corruption and doing that might fix it. The other approach would be to create a fresh form and copy all objects and code and properties to it (perhaps for all forms concerned). Doing both covers all angles.

As far as I'm aware. in theory (and in my experience) using the object pointer 'Me' in frmTitleOuter's module should always refer to itself so I expect corruption is the cause.
 

Users who are viewing this thread

Top Bottom