Random command buttons

  • Thread starter Thread starter Jordan
  • Start date Start date
J

Jordan

On my main input form, I have several buttons that seem
to be somewhat confused. Sometimes they work as intended,
other times they do nothing, as if there was no procedure
attached to them. This problem has only come up recently,
since I started changing object names. Does anybody have
any idea why they would work at some times and not at
others?

As a note, if I open it and they don't work, then they
won't work at all during that form "session". I have to
close the form, reopen it, and cross my fingers that
they'll work. If they do work, they will work during
that entire "session".
 
On my main input form, I have several buttons that seem
to be somewhat confused. Sometimes they work as intended,
other times they do nothing, as if there was no procedure
attached to them. This problem has only come up recently,
since I started changing object names. Does anybody have
any idea why they would work at some times and not at
others?

Check the Properties of the button. Each button's Click event should
contain either the name of a macro to be executed when you click it,
or (much more commonly and better) [Event procedure].

The problem can arise if you create a button with a Name property of
(let's say) Close. If you use the wizard to do so, it will create a
VBA procedure in the form's module which starts

Private Sub Close_Click()

If you now change the name of the button to cmdClose, the name of the
subroutine will NOT automatically change to

Private Sub cmdClose_Click()

Instead, you'll be left with an orphan routine, never executed from
any event (since there is no longer a control named Close), and your
cmdClose button won't have any associated event procedure.

Edit the Sub in your module and make sure that the names match; and be
sure that the event property shows [Event Procedure].
 
The names match, and the Event has it's procedure. But
even if that wasn't the case, it would never work.
However, it does work sometimes. The fact that it works
some of the time and not at other times is what doesn't
make sense to me. Thanks.

-----Original Message-----
On my main input form, I have several buttons that seem
to be somewhat confused. Sometimes they work as intended,
other times they do nothing, as if there was no procedure
attached to them. This problem has only come up recently,
since I started changing object names. Does anybody have
any idea why they would work at some times and not at
others?

Check the Properties of the button. Each button's Click event should
contain either the name of a macro to be executed when you click it,
or (much more commonly and better) [Event procedure].

The problem can arise if you create a button with a Name property of
(let's say) Close. If you use the wizard to do so, it will create a
VBA procedure in the form's module which starts

Private Sub Close_Click()

If you now change the name of the button to cmdClose, the name of the
subroutine will NOT automatically change to

Private Sub cmdClose_Click()

Instead, you'll be left with an orphan routine, never executed from
any event (since there is no longer a control named Close), and your
cmdClose button won't have any associated event procedure.

Edit the Sub in your module and make sure that the names match; and be
sure that the event property shows [Event Procedure].


.
 
Jordan said:
The names match, and the Event has it's procedure. But
even if that wasn't the case, it would never work.
However, it does work sometimes. The fact that it works
some of the time and not at other times is what doesn't
make sense to me. Thanks.

-----Original Message-----
On my main input form, I have several buttons that seem
to be somewhat confused. Sometimes they work as intended,
other times they do nothing, as if there was no procedure
attached to them. This problem has only come up recently,
since I started changing object names. Does anybody have
any idea why they would work at some times and not at
others?

Check the Properties of the button. Each button's Click event should
contain either the name of a macro to be executed when you click it,
or (much more commonly and better) [Event procedure].

The problem can arise if you create a button with a Name property of
(let's say) Close. If you use the wizard to do so, it will create a
VBA procedure in the form's module which starts

Private Sub Close_Click()

If you now change the name of the button to cmdClose, the name of the
subroutine will NOT automatically change to

Private Sub cmdClose_Click()

Instead, you'll be left with an orphan routine, never executed from
any event (since there is no longer a control named Close), and your
cmdClose button won't have any associated event procedure.

Edit the Sub in your module and make sure that the names match; and
be sure that the event property shows [Event Procedure].

I don't know if Name AutoCorrect could be the culprit, but try turning
it off: Tools -> Options -> General tab, uncheck "Track name
AutoCorrect info".
 
I tried that. Nothing. Does it even make sense to
anyone that it would work at some times and not at others?

-----Original Message-----
The names match, and the Event has it's procedure. But
even if that wasn't the case, it would never work.
However, it does work sometimes. The fact that it works
some of the time and not at other times is what doesn't
make sense to me. Thanks.

-----Original Message-----
On Tue, 17 Aug 2004 07:15:10 -0700, "Jordan"

On my main input form, I have several buttons that seem
to be somewhat confused. Sometimes they work as intended,
other times they do nothing, as if there was no procedure
attached to them. This problem has only come up recently,
since I started changing object names. Does anybody have
any idea why they would work at some times and not at
others?

Check the Properties of the button. Each button's Click event should
contain either the name of a macro to be executed when you click it,
or (much more commonly and better) [Event procedure].

The problem can arise if you create a button with a Name property of
(let's say) Close. If you use the wizard to do so, it will create a
VBA procedure in the form's module which starts

Private Sub Close_Click()

If you now change the name of the button to cmdClose, the name of the
subroutine will NOT automatically change to

Private Sub cmdClose_Click()

Instead, you'll be left with an orphan routine, never executed from
any event (since there is no longer a control named Close), and your
cmdClose button won't have any associated event procedure.

Edit the Sub in your module and make sure that the names match; and
be sure that the event property shows [Event Procedure].

I don't know if Name AutoCorrect could be the culprit, but try turning
it off: Tools -> Options -> General tab, uncheck "Track name
AutoCorrect info".

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

(please reply to the newsgroup)


.
 
Jordan said:
I tried that. Nothing. Does it even make sense to
anyone that it would work at some times and not at others?

Aside from the possible malfeasance of AutoCorrect, if the buttons
simply may or may not work, each time you open the form (and without
changing anything else), I can't think of any possible cause except some
form of weird corruption. Have you tried creating a new, blank database
and importing all objects from the old one into the new one? That
sometimes gets rid of corruption, or at least identifies objects that
are corrupted.
 
I tried creating a new and importing all objects, but
that didn't work. Same thing. I've even tried creating
the buttons from scratch, and they still do the same
thing. It's the strangest thing I've ever seen. Thanks
for the help. I guess it's not the end of the world.
Now if only I can figure out that merging problem...

Jordan
 
Jordan said:
I tried creating a new and importing all objects, but
that didn't work. Same thing. I've even tried creating
the buttons from scratch, and they still do the same
thing. It's the strangest thing I've ever seen. Thanks
for the help. I guess it's not the end of the world.
Now if only I can figure out that merging problem...

Very odd. The only other thing I can think of is a broken reference
that isn't always discovered. So (I'm speculating here) things run
along smoothly until that reference is needed; then it's found to be
broken and your VB project no longer works right. Maybe. But really,
your statement that it only started happening after you started renaming
objects really suggested the other possibilities we've already talked
about.

If you'd like to send me a cut-down copy of your database, containing
only the elements necessary to demonstrate the problem, compacted and
then zipped to less than 1MB in size (preferably much smaller) -- I'll
have a look at it, time permitting. You can send it to the address
derived by removing NO SPAM from the reply address of this message.
 
Back
Top