dbTalk Databases Forums  

use of Me. gives RunTime error

comp.databases.ms-access comp.databases.ms-access


Discuss use of Me. gives RunTime error in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
olaf
 
Posts: n/a

Default use of Me. gives RunTime error - 08-12-2005 , 09:25 AM






Hi!

When using the "me." keyword (for ex. me.FilterOn = True), I sometimes
(not always) get the error message:
"The expression yuo entered refers to an object that is closed or
doesn't exist."

I really wonder why. I use it in a Form-module, to reference the form
itself. The form is used as a subform in another form. Could that be
the reason?

Please help!
-Olaf


Reply With Quote
  #2  
Old   
Ed Robichaud
 
Posts: n/a

Default Re: use of Me. gives RunTime error - 08-12-2005 , 12:52 PM






I'm surprised that it works at any time. Below is a handy sheet to correct
syntax.







Syntax for main/subforms



For these examples:

Mainform is the name of the top level form

Subform1 is the name of the subform CONTROL on mainform

Subform2 is the name of the subform CONTROL on the 1st subform.




If you are on



Main form
Sub 1

To refer to a form property, like RecordSource



On Mainform
Me.RecordSource
Me.Parent.RecordSource

On Sub 1
Me!Subform1.Form.RecordSource
Me.RecordSource

On Sub 2
Me!Subform1.Form!Subform2.Form.

RecordSource
Me!Subform2.Form.RecordSource

To refer to a control



On Mainform
Me!ControlName
Me.Parent!ControlName

On Sub 1
Me!Subform1.Form!ControlName
Me!ControlName

On Sub 2
Me!Subform1.Form!Subform2.Form!

ControlName
Me!Subform2.Form!ControlName

To refer to a control property, like Enabled



On Mainform
Me!ControlName.Enabled
Me.Parent!ControlName.Enabled

On Sub 1
Me!Subform1.Form!ControlName.Enabled
Me!ControlName.Enabled

On Sub 2
Me!Subform1.Form!Subform2.Form!

ControlName.Enabled
Me!Subform2.Form!ControlName.Enabled

To refer to a subform control property, like SourceObject



On Mainform
N/A
N/A

On Sub 1
Me!Subform1.SourceObject
N/A

On Sub 2
Me!Subform1.Form!Subform2.SourceObject
Me!Subform2.SourceObject






If you are on



Sub2
Not in these forms

To refer to a form property, like RecordSource



On Mainform
Me.Parent.Parent.RecordSource
Forms!Mainform.RecordSource

On Sub 1
Me.Parent.RecordSource
Forms!Mainform!Subform1.Form.RecordSource

On Sub 2
Me.RecordSource
Forms!Mainform!Subform1.Form!Subform2.

Form.RecordSource

To refer to a control



On Mainform
Me.Parent.Parent!ControlName
Forms!Mainform!ControlName

On Sub 1
Me.Parent!ControlName
Forms!Mainform!Subform1.Form!ControlName

On Sub 2
Me!ControlName
Forms!Mainform!Subform1.Form!Subform2.

Form!ControlName

To refer to a control property, like Enabled



On Mainform
Me.Parent.Parent!ControlName.Enabled
Forms!Mainform!ControlName.Enabled

On Sub 1
Me.Parent!ControlName.Enabled
Forms!Mainform!Subform1.Form!ControlName.Enabled

On Sub 2
Me!ControlName.Enabled
Forms!Mainform!Subform1.Form!Subform2.

Form!ControlName.Enabled

To refer to a subform control property, like SourceObject



On Mainform
N/A
N/A

On Sub 1
N/A
Forms!Mainform!Subform1.SourceObject

On Sub 2
N/A
Forms!Mainform!Subform1.Form!Subform2.

SourceObject




"olaf" <olafn (AT) runit (DOT) no> wrote

Quote:
Hi!

When using the "me." keyword (for ex. me.FilterOn = True), I sometimes
(not always) get the error message:
"The expression yuo entered refers to an object that is closed or
doesn't exist."

I really wonder why. I use it in a Form-module, to reference the form
itself. The form is used as a subform in another form. Could that be
the reason?

Please help!
-Olaf




Reply With Quote
  #3  
Old   
David W. Fenton
 
Posts: n/a

Default Re: use of Me. gives RunTime error - 08-12-2005 , 03:21 PM



"Ed Robichaud" <edrobichaud (AT) wdn (DOT) com> wrote in
news:bt4Le.976$MP5.79948 (AT) monger (DOT) newsread.com:

Quote:
I'm surprised that it works at any time. Below is a handy sheet
to correct syntax.
How completely idiotic.

Of course, Me.FilterOn should work in the module of a subform.

If you want to check it from outside that context, say while the
main form with the embedded subform is open, you can test it from
the Debug window with:

Forms!MainForm!SubForm.Form.FilterOn

Now, I've seen some complexities with filters in subforms, but
nothing that's insurmountable. Perhaps if the original poster could
indicate what exact line is causing the error, it would be more
easily diagnosable.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc


Reply With Quote
  #4  
Old   
Cathy Gilroy
 
Posts: n/a

Default Re: use of Me. gives RunTime error - 08-12-2005 , 07:38 PM




"Ed Robichaud" <edrobichaud (AT) wdn (DOT) com> wrote

Quote:
I'm surprised that it works at any time. Below is a handy sheet to
correct syntax.
Ed--Disregard David's post. He's having his period. (His asshole is
bleeding.) --Cathy




Reply With Quote
  #5  
Old   
Douglas J. Steele
 
Posts: n/a

Default Re: use of Me. gives RunTime error - 08-13-2005 , 08:03 AM



You probably should have mentioned that what you posted was copied from
http://www.mvps.org/access/forms/frm0031.htm at "The Access Web". In that
way, he could go there and see it formatted (and even download the doc
version)

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)



"Ed Robichaud" <edrobichaud (AT) wdn (DOT) com> wrote

Quote:
I'm surprised that it works at any time. Below is a handy sheet to
correct syntax.


"olaf" <olafn (AT) runit (DOT) no> wrote in message
news:1123853142.831456.114190 (AT) z14g2000cwz (DOT) googlegroups.com...
Hi!

When using the "me." keyword (for ex. me.FilterOn = True), I sometimes
(not always) get the error message:
"The expression yuo entered refers to an object that is closed or
doesn't exist."

I really wonder why. I use it in a Form-module, to reference the form
itself. The form is used as a subform in another form. Could that be
the reason?

Please help!
-Olaf






Reply With Quote
  #6  
Old   
XMVP
 
Posts: n/a

Default Re: use of Me. gives RunTime error - 08-13-2005 , 12:29 PM




According to Arvin Meyer MCP (Master Certified Plagiarist) you don't have to
mention where you stole stuff from.



"Douglas J. Steele" <NOSPAM_djsteele (AT) NOSPAM_canada (DOT) com> wrote

Quote:
You probably should have mentioned that what you posted was copied from
http://www.mvps.org/access/forms/frm0031.htm at "The Access Web". In that
way, he could go there and see it formatted (and even download the doc
version)

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)



"Ed Robichaud" <edrobichaud (AT) wdn (DOT) com> wrote in message
news:bt4Le.976$MP5.79948 (AT) monger (DOT) newsread.com...
I'm surprised that it works at any time. Below is a handy sheet to
correct syntax.


"olaf" <olafn (AT) runit (DOT) no> wrote in message
news:1123853142.831456.114190 (AT) z14g2000cwz (DOT) googlegroups.com...
Hi!

When using the "me." keyword (for ex. me.FilterOn = True), I sometimes
(not always) get the error message:
"The expression yuo entered refers to an object that is closed or
doesn't exist."

I really wonder why. I use it in a Form-module, to reference the form
itself. The form is used as a subform in another form. Could that be
the reason?

Please help!
-Olaf








Reply With Quote
  #7  
Old   
Ed Robichaud
 
Posts: n/a

Default Re: use of Me. gives RunTime error - 08-20-2005 , 07:53 PM



Thanks; I couldn't find that web page reference, but thought I'd sent the
info in HTML to preserve the doc formatting.
-Ed

"Douglas J. Steele" <NOSPAM_djsteele (AT) NOSPAM_canada (DOT) com> wrote

Quote:
You probably should have mentioned that what you posted was copied from
http://www.mvps.org/access/forms/frm0031.htm at "The Access Web". In that
way, he could go there and see it formatted (and even download the doc
version)

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)



"Ed Robichaud" <edrobichaud (AT) wdn (DOT) com> wrote in message
news:bt4Le.976$MP5.79948 (AT) monger (DOT) newsread.com...
I'm surprised that it works at any time. Below is a handy sheet to
correct syntax.


"olaf" <olafn (AT) runit (DOT) no> wrote in message
news:1123853142.831456.114190 (AT) z14g2000cwz (DOT) googlegroups.com...
Hi!

When using the "me." keyword (for ex. me.FilterOn = True), I sometimes
(not always) get the error message:
"The expression yuo entered refers to an object that is closed or
doesn't exist."

I really wonder why. I use it in a Form-module, to reference the form
itself. The form is used as a subform in another form. Could that be
the reason?

Please help!
-Olaf








Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.