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. |
|
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
"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
|
|||
|
|||
"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
|
|||
|
|||
"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
|
|||
|
|||
"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
|
|||
|
|||
"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
|
|||
|
|||
"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
|
|||
|
|||
"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
|
|||
|
|||
"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
|
|||
|
|||
"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
|
|||
|
|||
"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 | |
|
|
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 |