Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old February 27th, 2007, 05:15 PM
ApexData@gmail.com
Guest
 
Posts: n/a
Default ClickEvent Function Problem

I found the following code which allows me to sort on the click event
of a labelbutton.

The problem occurs when I try to call the function directly from the
ClickEvent, instead of having the ClickEvent run its subroutine.
Any Ideas??

'THIS DOES NOT WORK:
= SortForm([Me],"CRNAME")
'The error is:
'The object doesn't contain the Automation object 'ME.'.

'THIS WORKS:
Private Sub lblSort1_Click()
Call SortForm(Me, "CRNAME")
End Sub

' this code is in Module1
Public Function SortForm(frm As Form, ByVal sOrderBy As String)
'Purpose: Set a form's OrderBy to the string. Reverse if already set.
'Return: True if success.
'Usage: Command button above a column in a continuous form:
' Call SortForm(Me, "MyField")
If Len(sOrderBy) 0 Then
' Reverse the order if already sorted this way.
If frm.OrderByOn And (frm.OrderBy = sOrderBy) Then
sOrderBy = sOrderBy & " DESC"
End If
frm.OrderBy = sOrderBy
frm.OrderByOn = True
End If
End Function

Thanks

  #2  
Old February 27th, 2007, 05:25 PM
storrboy
Guest
 
Posts: n/a
Default Re: ClickEvent Function Problem

On Feb 27, 12:08 pm, "ApexD...@gmail.com" <ApexD...@gmail.comwrote:
Quote:
I found the following code which allows me to sort on the click event
of a labelbutton.
>
The problem occurs when I try to call the function directly from the
ClickEvent, instead of having the ClickEvent run its subroutine.
Any Ideas??
>
'THIS DOES NOT WORK:
= SortForm([Me],"CRNAME")
'The error is:
'The object doesn't contain the Automation object 'ME.'.
>
'THIS WORKS:
Private Sub lblSort1_Click()
Call SortForm(Me, "CRNAME")
End Sub
>
' this code is in Module1
Public Function SortForm(frm As Form, ByVal sOrderBy As String)
'Purpose: Set a form's OrderBy to the string. Reverse if already set.
'Return: True if success.
'Usage: Command button above a column in a continuous form:
' Call SortForm(Me, "MyField")
If Len(sOrderBy) 0 Then
' Reverse the order if already sorted this way.
If frm.OrderByOn And (frm.OrderBy = sOrderBy) Then
sOrderBy = sOrderBy & " DESC"
End If
frm.OrderBy = sOrderBy
frm.OrderByOn = True
End If
End Function
>
Thanks
Me is a keyword only availbe in VB. It does not exist outside a code
module.
If you need the function directly in the event property box, you'll
likely have to refer to the form explicitly.
= SortForm(Forms!FormName,"CRNAME")

I think it's better to leave it in the event proceedure anyway.

  #3  
Old February 27th, 2007, 05:55 PM
ApexData@gmail.com
Guest
 
Posts: n/a
Default Re: ClickEvent Function Problem

ThanksMike
Quote:
>I think it's better to leave it in the event proceedure anyway.
Since I will use this for quite a few fields, I thought it best to
avoid cluttering my existing code with all the extra procedures.

= SortForm(Forms!FormName,"CRNAME")
This worked great!

ThanksAgain
Greg





  #4  
Old February 27th, 2007, 07:05 PM
Marshall Barton
Guest
 
Posts: n/a
Default Re: ClickEvent Function Problem

ApexData@gmail.com wrote:
Quote:
>I found the following code which allows me to sort on the click event
>of a labelbutton.
>
>The problem occurs when I try to call the function directly from the
>ClickEvent, instead of having the ClickEvent run its subroutine.
>Any Ideas??
>
>'THIS DOES NOT WORK:
>= SortForm([Me],"CRNAME")
>'The error is:
>'The object doesn't contain the Automation object 'ME.'.

[Form] (or [Report]) is the equivalent of [Me] in a control
source or property expression.

--
Marsh
  #5  
Old February 27th, 2007, 09:15 PM
storrboy
Guest
 
Posts: n/a
Default Re: ClickEvent Function Problem

On Feb 27, 1:56 pm, Marshall Barton <marshbar...@wowway.comwrote:
Quote:
ApexD...@gmail.com wrote:
Quote:
I found the following code which allows me to sort on the click event
of a labelbutton.
>
Quote:
The problem occurs when I try to call the function directly from the
ClickEvent, instead of having the ClickEvent run its subroutine.
Any Ideas??
>
Quote:
'THIS DOES NOT WORK:
= SortForm([Me],"CRNAME")
'The error is:
'The object doesn't contain the Automation object 'ME.'.
>
[Form] (or [Report]) is the equivalent of [Me] in a control
source or property expression.
>
--
Marsh

Without the name?
I didn't know that if so.

 

Bookmarks

Thread Tools

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

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles