473,506 Members | 17,266 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What happened to the CommandButton_Click event?

stonward
145 New Member
Evening All,

Forgive me, but this question is related to my last question...

In Access 2002 I used a simple "buttonname_Click" command to activate a button on a form from another form.

When I try this in version 2007, i get a 'Method or data member not found' error: although intellisense adds all the right capital letters etc. It fails on Compile too; the code doesn't need to be run.

Did anyone else us this command previously, and is there an equivilent now?

Thankyou for your patience,


Stonward
Jan 31 '13 #1
9 2301
Seth Schrock
2,965 Recognized Expert Specialist
So your sub looks like the following?

Expand|Select|Wrap|Line Numbers
  1. Private Sub ButtonName_Click()
  2.  
  3. End Sub
And when you debug the code, it selects the first line?

Try going into your button's event list in the properties window and create the event through that instead of manually typing in the code.
Jan 31 '13 #2
zmbd
5,501 Recognized Expert Moderator Expert
I find that all too often, I'll cut and paste a button code (usually the "close/exit" button) and it fails with that error; Because, you have to establish the "click" event first thru the properties dialog box. This does two things, it adds the "sub()" to the VBA editor that we're used to working with and it adds a pointer to the event within the collection.
Jan 31 '13 #3
NeoPa
32,557 Recognized Expert Moderator MVP
My first bit of advice is to avoid doing that. Never call event procedures directly from code. A maintainer is likely to get caught out.

That said, can you show us the exact code you're trying. Without it, and without your question explaining all the details fully, we are left guessing at whether or not the reference is qualified or otherwise; whether the declaration is Public or Private (If the latter then it would never have worked of course).
Jan 31 '13 #4
stonward
145 New Member
The button on the 'main' form, cmdReset has a click event attached to it and works correctly. Looking back at what I've done before, it would seem I've called 'that' (a) buttons click event from another button on the same form, where simply entering cmdReset_Click works. I thought if I qualified everything I'd be able to do the same from another form, but doesn't look like its possible.

Interesting point about calling procedures from code NeoPa - it's the sort of thing I'm always trying! I've another question now, so hopefully I'll speak to you all again soon.

Many thanks for your help; it can be a lonely place working on these projects and having someone (other than my dog) to tell is a great help!

stonward
Jan 31 '13 #5
TheSmileyCoder
2,322 Recognized Expert Moderator Top Contributor
You can call a click event from another form BUT you need to first modify the default code
Expand|Select|Wrap|Line Numbers
  1. Private Sub MyButtonName_Click()
  2.  
  3. End sub
to change the private to public
Expand|Select|Wrap|Line Numbers
  1. Public Sub MyButtonName_Click()
  2.  
  3. End sub
This is not enough though, you now need to fully qualify the forms like so:
Expand|Select|Wrap|Line Numbers
  1. Call Forms!Frm_Main!MyButtonName_Click
Jan 31 '13 #6
stonward
145 New Member
Thanks TheSmileyCoder. I tried making the button event public, now going to check I've done that AND fully qualified all names.

Get back to you.

Thanks again,

Stonward
Jan 31 '13 #7
stonward
145 New Member
TheSmileyCoder: spot on - that did it...make button public, make sure everything is fully named/called in the originating code. Now my listbox updates automatically!

Super Thanks,

Stonward
Jan 31 '13 #8
TheSmileyCoder
2,322 Recognized Expert Moderator Top Contributor
Thats good to hear. Best of luck with your project.
Jan 31 '13 #9
NeoPa
32,557 Recognized Expert Moderator MVP
I feel I need to repeat that fully specified external references are not a good idea when called from within the associated form's module. If a Me reference will work, then it really should be used in place of an external reference.
Jan 31 '13 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1273
by: JW | last post by:
Hi all, I was fine running mysql, and for some reason, after the most recent reboot of my machine, I get the following error and I try the following subsequent commands to try to figure things...
7
1801
by: Neil Zanella | last post by:
OK, this time the compiler's got me a little bit puzzled, simply because it is doing something I am not expecting. My understanding, according to the documentation of std::vector<>::resize(), is...
2
1992
by: Lauren Wilson | last post by:
Hi folks, Just "upgraded" from A2K to A2K3. Everything is just hunky dory (so far) -- EXCEPT that the Add-in I had with A2K that auto inserts error code is no longer available in the Add-in...
1
2273
by: Mikey | last post by:
Can somebody tell me what happened to the Source Profiler? It used to be under the Build menu in VC6, but now it's gone, and I cannot find anything in the docs that say what happened to it. The...
4
3090
by: Alan Silver | last post by:
Hello, I downloaded and registered VWD Express from the MS site, and this gave me a free download of a book called "Build A Web Site Now!", which is a (very light) introduction to VWD. In the...
2
1264
by: Alex D. | last post by:
does any body knows what happened to the demo servers?
5
1551
by: rodchar | last post by:
hey all, what happened to being able to compile my app as Release version? thanks, rodchar
9
3695
by: jacob navia | last post by:
??? Not that I miss his posts, but somehow I find sad that somebody disappears from view and nobody gives a damm. Anybody knows what happened to him? He had lost is job, and was looking for...
3
2147
by: Giampaolo Rodola' | last post by:
http://groups.google.com/group/python-dev2 It seems it no longer exists. What happened?
0
7105
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
7371
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
7479
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
5617
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3188
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3178
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1534
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
410
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.