A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

"Me" Variable in Property Sheet



 
 
Thread Tools Display Modes
  #1  
Old November 2nd, 2005, 09:45 PM
Tom via AccessMonster.com
external usenet poster
 
Posts: n/a
Default "Me" Variable in Property Sheet

Is it possible to use the Me variable in the properties sheet for a command
button? For example: I want to use :

=ChangeFormColor([Me])

as the On Click event in the properties window instead of:

=ChangeFormColor([Forms]![frmMainForm]).

The function ChangeFormColor is:

Function ChangeFormColor(frm As Form)
On Error Resume Next
frm.Detail.BackColor = RGB(Rnd * 256, Rnd * 256, Rnd * 256)
End Function

Thanks in advance.

Tom


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200511/1
  #2  
Old November 2nd, 2005, 10:20 PM
Douglas J. Steele
external usenet poster
 
Posts: n/a
Default "Me" Variable in Property Sheet

Either use VBA code to call the function (without the square brackets around
Me), or try changing your function to:

Function ChangeFormColor(Optional frm As Variant)
On Error Resume Next
If IsMissing(frm) Then
Set frm = Screen.ActiveForm
End If
frm.Detail.BackColor = RGB(Rnd * 256, Rnd * 256, Rnd * 256)
End Function

and simply use =ChangeFormColor() when you want to change the current form.

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



"Tom via AccessMonster.com" u14151@uwe wrote in message
news:56c70f4b4512e@uwe...
Is it possible to use the Me variable in the properties sheet for a
command
button? For example: I want to use :

=ChangeFormColor([Me])

as the On Click event in the properties window instead of:

=ChangeFormColor([Forms]![frmMainForm]).

The function ChangeFormColor is:

Function ChangeFormColor(frm As Form)
On Error Resume Next
frm.Detail.BackColor = RGB(Rnd * 256, Rnd * 256, Rnd * 256)
End Function

Thanks in advance.

Tom


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200511/1



  #3  
Old November 2nd, 2005, 10:21 PM
Jeff Boyce
external usenet poster
 
Posts: n/a
Default "Me" Variable in Property Sheet

Tom

What happens when you try this?

Jeff Boyce
Office/Access MVP

"Tom via AccessMonster.com" u14151@uwe wrote in message
news:56c70f4b4512e@uwe...
Is it possible to use the Me variable in the properties sheet for a
command
button? For example: I want to use :

=ChangeFormColor([Me])

as the On Click event in the properties window instead of:

=ChangeFormColor([Forms]![frmMainForm]).

The function ChangeFormColor is:

Function ChangeFormColor(frm As Form)
On Error Resume Next
frm.Detail.BackColor = RGB(Rnd * 256, Rnd * 256, Rnd * 256)
End Function

Thanks in advance.

Tom


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200511/1



  #4  
Old November 2nd, 2005, 10:51 PM
Klatuu
external usenet poster
 
Posts: n/a
Default "Me" Variable in Property Sheet

Yep, it works. Looks pretty cool. I did not put the square brackets around
Me. Curious as to why you made it a function if it returns nothing, why not
a Sub? It works fine as a sub.

"Tom via AccessMonster.com" wrote:

Is it possible to use the Me variable in the properties sheet for a command
button? For example: I want to use :

=ChangeFormColor([Me])

as the On Click event in the properties window instead of:

=ChangeFormColor([Forms]![frmMainForm]).

The function ChangeFormColor is:

Function ChangeFormColor(frm As Form)
On Error Resume Next
frm.Detail.BackColor = RGB(Rnd * 256, Rnd * 256, Rnd * 256)
End Function

Thanks in advance.

Tom


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200511/1

  #5  
Old November 3rd, 2005, 06:27 AM
Dirk Goldgar
external usenet poster
 
Posts: n/a
Default "Me" Variable in Property Sheet

"Tom via AccessMonster.com" u14151@uwe wrote in message
news:56c70f4b4512e@uwe
Is it possible to use the Me variable in the properties sheet for a
command button? For example: I want to use :

=ChangeFormColor([Me])

as the On Click event in the properties window instead of:

=ChangeFormColor([Forms]![frmMainForm]).

The function ChangeFormColor is:

Function ChangeFormColor(frm As Form)
On Error Resume Next
frm.Detail.BackColor = RGB(Rnd * 256, Rnd * 256, Rnd * 256)
End Function

Thanks in advance.

Tom


I've always done this by referring to the form's Form property, as in:

=ChangeFormColor([Form])

If [Me] works, it's news to me.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


  #6  
Old November 3rd, 2005, 12:12 PM
Douglas J Steele
external usenet poster
 
Posts: n/a
Default "Me" Variable in Property Sheet

You can't put a Sub as an Event property, whereas you can put a Function
there.

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


"Klatuu" wrote in message
...
Yep, it works. Looks pretty cool. I did not put the square brackets

around
Me. Curious as to why you made it a function if it returns nothing, why

not
a Sub? It works fine as a sub.

"Tom via AccessMonster.com" wrote:

Is it possible to use the Me variable in the properties sheet for a

command
button? For example: I want to use :

=ChangeFormColor([Me])

as the On Click event in the properties window instead of:

=ChangeFormColor([Forms]![frmMainForm]).

The function ChangeFormColor is:

Function ChangeFormColor(frm As Form)
On Error Resume Next
frm.Detail.BackColor = RGB(Rnd * 256, Rnd * 256, Rnd * 256)
End Function

Thanks in advance.

Tom


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200511/1



  #7  
Old November 3rd, 2005, 01:04 PM
Tom via AccessMonster.com
external usenet poster
 
Posts: n/a
Default "Me" Variable in Property Sheet

Jeff: Using the Me variable returns a error message "The object doesn't
contain the Automation object 'Me'."

Dirk & Douglas: Both of your suggestions work. Thanks.

Tom



Dirk Goldgar wrote:
Is it possible to use the Me variable in the properties sheet for a
command button? For example: I want to use :

[quoted text clipped - 15 lines]

Tom


I've always done this by referring to the form's Form property, as in:

=ChangeFormColor([Form])

If [Me] works, it's news to me.



--
Message posted via http://www.accessmonster.com
  #8  
Old November 3rd, 2005, 01:14 PM
Klatuu
external usenet poster
 
Posts: n/a
Default "Me" Variable in Property Sheet

ChangeFormColor would not be a valid name for an event function.

"Douglas J Steele" wrote:

You can't put a Sub as an Event property, whereas you can put a Function
there.

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


"Klatuu" wrote in message
...
Yep, it works. Looks pretty cool. I did not put the square brackets

around
Me. Curious as to why you made it a function if it returns nothing, why

not
a Sub? It works fine as a sub.

"Tom via AccessMonster.com" wrote:

Is it possible to use the Me variable in the properties sheet for a

command
button? For example: I want to use :

=ChangeFormColor([Me])

as the On Click event in the properties window instead of:

=ChangeFormColor([Forms]![frmMainForm]).

The function ChangeFormColor is:

Function ChangeFormColor(frm As Form)
On Error Resume Next
frm.Detail.BackColor = RGB(Rnd * 256, Rnd * 256, Rnd * 256)
End Function

Thanks in advance.

Tom


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200511/1




  #9  
Old November 3rd, 2005, 02:11 PM
Klatuu
external usenet poster
 
Posts: n/a
Default "Me" Variable in Property Sheet

I liked the routine you wrote and thought it might be interesting to use it
for getting a user's attention if there is an error, so I embellished it
little.

Sub FlashFormColor(frm As Form, lngDuration As Integer, lngSpeed As Long)
Dim lngOldColor As Long
Dim lngCtr As Long
On Error Resume Next
lngOldColor = frm.Detail.BackColor
For lngCtr = 0 To lngDuration
frm.Detail.BackColor = RGB(Rnd * 256, Rnd * 256, Rnd * 256)
frm.Repaint
Call sSleep(lngSpeed)
Next lngCtr
frm.Detail.BackColor = lngOldColor

End Sub


"Tom via AccessMonster.com" wrote:

Jeff: Using the Me variable returns a error message "The object doesn't
contain the Automation object 'Me'."

Dirk & Douglas: Both of your suggestions work. Thanks.

Tom



Dirk Goldgar wrote:
Is it possible to use the Me variable in the properties sheet for a
command button? For example: I want to use :

[quoted text clipped - 15 lines]

Tom


I've always done this by referring to the form's Form property, as in:

=ChangeFormColor([Form])

If [Me] works, it's news to me.



--
Message posted via http://www.accessmonster.com

  #10  
Old November 3rd, 2005, 04:22 PM
Douglas J Steele
external usenet poster
 
Posts: n/a
Default "Me" Variable in Property Sheet

Why do you say that?

I tested the code I suggested to Tom, and it worked fine putting
=ChangeFormColor() in the form's Property Sheet for the Click event of a
button.

An event property can be set to any of:
1) Macro (use "macroname" as the property)
2) Event procedure (use "[Event Procedure]" as the property, and then have a
corresponding Sub in the form's class)
3) User-defined function (use something like "=functionname( )" as the
property)


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


"Klatuu" wrote in message
...
ChangeFormColor would not be a valid name for an event function.

"Douglas J Steele" wrote:

You can't put a Sub as an Event property, whereas you can put a Function
there.

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


"Klatuu" wrote in message
...
Yep, it works. Looks pretty cool. I did not put the square brackets

around
Me. Curious as to why you made it a function if it returns nothing,

why
not
a Sub? It works fine as a sub.

"Tom via AccessMonster.com" wrote:

Is it possible to use the Me variable in the properties sheet for a

command
button? For example: I want to use :

=ChangeFormColor([Me])

as the On Click event in the properties window instead of:

=ChangeFormColor([Forms]![frmMainForm]).

The function ChangeFormColor is:

Function ChangeFormColor(frm As Form)
On Error Resume Next
frm.Detail.BackColor = RGB(Rnd * 256, Rnd * 256, Rnd * 256)
End Function

Thanks in advance.

Tom


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200511/1






 




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 Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic reference to a sheet xisque Worksheet Functions 4 June 20th, 2005 09:04 PM
Copying multiple sheets from one book 2 another and undertake spec Pank Mehta General Discussion 14 March 16th, 2005 04:41 PM
Property Sheet Access 2003 Ant General Discussion 1 July 20th, 2004 04:03 AM
Relative Reference to another sheet? Gary Worksheet Functions 5 March 23rd, 2004 11:10 PM
Sheet copy with absolute reverence Peo Sjoblom Worksheet Functions 0 November 17th, 2003 08:16 PM


All times are GMT +1. The time now is 09:27 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.