473,402 Members | 2,072 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

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

Feb 27 '07 #1
4 2123
On Feb 27, 12:08 pm, "ApexD...@gmail.com" <ApexD...@gmail.comwrote:
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.

Feb 27 '07 #2
ThanksMike
>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

Feb 27 '07 #3
Ap******@gmail.com wrote:
>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
Feb 27 '07 #4
On Feb 27, 1:56 pm, Marshall Barton <marshbar...@wowway.comwrote:
ApexD...@gmail.com wrote:
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

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

Feb 27 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Kostatus | last post by:
I have a virtual function in a base class, which is then overwritten by a function of the same name in a publically derived class. When I call the function using a pointer to the derived class...
4
by: andy | last post by:
i am coding a dll which contains a function take a const wchar_t* as parameter, call it form a exe, the wchar_t is passed to dll function, but the function in dll will then call another function...
1
by: Arne Petersen | last post by:
Hy, I've got a problem with member function templates compiled into libraries. I'm trying to get a library collection (coded for GNU gcc, where its compiled completly) being compiled on Visual...
3
by: Jan-Henrik Grobe | last post by:
Hallo, I am coming to this newsgroup with a very strange Problem. I have two c++ files A.cpp and B.cpp....In A.cpp I am creating an openGL window and in B.cpp I have stored the callback...
2
by: Hennie de Nooijer | last post by:
Because of an error in google or underlying site i can reply on my own issue. Therefore i copied the former entered message in this message....
7
by: Mike D. | last post by:
I have a problem with a dynamic library I am developing, but it is really more of a pointer issue than anything else. Hopefully someone here can lend me some assistance or insight into resolving...
2
by: Fernando Barsoba | last post by:
Dear all, I have been posting about a problem trying to encrypt certain data using HMAC-SHA1 functions. I posted that my problem was solved, but unfortunately, I was being overly optimistic. I...
78
by: Josiah Manson | last post by:
I found that I was repeating the same couple of lines over and over in a function and decided to split those lines into a nested function after copying one too many minor changes all over. The only...
6
by: RandomElle | last post by:
Hi there I'm hoping someone can help me out with the use of the Eval function. I am using Access2003 under WinXP Pro. I can successfully use the Eval function and get it to call any function with...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.