By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,962 Members | 1,791 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,962 IT Pros & Developers. It's quick & easy.

OnClick event not firing

P: n/a
I have an Access 2003 form bound to a SQL Server table via ODBC.
Often clicking a button on the form has the effect of requerying the
form rather than firing the OnClick event. Does anyone have an
explanation? Is this evidence of corruption, or a known side effect?

TIA

Bruce
Sep 23 '08 #1
Share this Question
Share on Google+
21 Replies


P: n/a
br********@comcast.net wrote:
I have an Access 2003 form bound to a SQL Server table via ODBC.
Often clicking a button on the form has the effect of requerying the
form rather than firing the OnClick event. Does anyone have an
explanation? Is this evidence of corruption, or a known side effect?
Never heard of it. Ever. I suppose that means corruption is possible, but
only some of the time?

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Sep 24 '08 #2

P: n/a
br********@comcast.net wrote in
news:57**********************************@e39g2000 hsf.googlegroups.co
m:
I have an Access 2003 form bound to a SQL Server table via ODBC.
Often clicking a button on the form has the effect of requerying
the form rather than firing the OnClick event. Does anyone have
an explanation? Is this evidence of corruption, or a known side
effect?
What does the code in the OnClick event of the command button do?

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Sep 24 '08 #3

P: n/a
"David W. Fenton" <XX*******@dfenton.com.invalidwrote in message
news:Xn**********************************@74.209.1 36.89...
br********@comcast.net wrote in
news:57**********************************@e39g2000 hsf.googlegroups.co
m:
>I have an Access 2003 form bound to a SQL Server table via ODBC.
Often clicking a button on the form has the effect of requerying
the form rather than firing the OnClick event. Does anyone have
an explanation? Is this evidence of corruption, or a known side
effect?

What does the code in the OnClick event of the command button do?

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
I've run into something similar, sometimes. If I change the name of some
controls, sometimes the event linked to that control gets "lost" somehow. To
fix, I exit the VBA code and return to form design view. Then I select the
properties window of the failing control. Then I cursor down to the
associated event. Normally the event should say [Event Procedure]. But when
it's "lost", the property is blank. So I click on the ellipsis (...) and
select "code builder". That opens the VBA code and re-establishes the link
to my coded event.
Fred Zuckerman
Sep 24 '08 #4

P: n/a
"Fred Zuckerman" <Zu********@sbcglobal.netwrote in
news:%F****************@nlpi069.nbdc.sbc.com:
"David W. Fenton" <XX*******@dfenton.com.invalidwrote in message
news:Xn**********************************@74.209.1 36.89...
>br********@comcast.net wrote in
news:57**********************************@e39g200 0hsf.googlegroups
.co m:
>>I have an Access 2003 form bound to a SQL Server table via ODBC.
Often clicking a button on the form has the effect of requerying
the form rather than firing the OnClick event. Does anyone
have an explanation? Is this evidence of corruption, or a known
side effect?

What does the code in the OnClick event of the command button do?

I've run into something similar, sometimes. If I change the name
of some controls, sometimes the event linked to that control gets
"lost" somehow.
That isn't surprising. Access has always worked that way, such that
changing the name of a control always disconnected it from its
events.
To
fix, I exit the VBA code and return to form design view. Then I
select the properties window of the failing control. Then I cursor
down to the associated event. Normally the event should say [Event
Procedure]. But when it's "lost", the property is blank. So I
click on the ellipsis (...) and select "code builder". That opens
the VBA code and re-establishes the link to my coded event.
That doesn't always work. I always cut the old code to the
clipboard, and start over from scratch.

I'm not sure what any of that has to with the original problem -- if
the code is disconnected, it shouldn't cause the record to be saved
no matter what.

My whole question about the code behind the command button is
whether or not something in the code is causing the record save as a
side effect of something else that the code is doing.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Sep 24 '08 #5

P: n/a
On Sep 23, 10:28*pm, "David W. Fenton" <XXXuse...@dfenton.com.invalid>
wrote:
brucedo...@comcast.net wrote innews:57**********************************@e39g20 00hsf.googlegroups.co
m:
I have an Access 2003 form bound to a SQL Server table via ODBC.
Often clicking a button on the form has the effect of requerying
the form rather than firing the OnClick event. * Does anyone have
an explanation? *Is this evidence of corruption, or a known side
effect?

What does the code in the OnClick event of the command button do?

--
David W. Fenton * * * * * * * * *http://www.dfenton.com/
usenet at dfenton dot com * *http://www.dfenton.com/DFA/
Here's a sample, but this is not the only button for which this
occurs:
Private Sub cmdRebuildClientSProc_Click()
'22)
If Len(Trim(Nz(cmbClient, ""))) = 5 Then
DraftRebuild cmbClient
Else
MsgBox "Please select a valid client"
End If
End Sub
Sep 25 '08 #6

P: n/a
On Sep 23, 10:33*pm, "Fred Zuckerman" <Zuckerm...@sbcglobal.net>
wrote:
"David W. Fenton" <XXXuse...@dfenton.com.invalidwrote in messagenews:Xn**********************************@7 4.209.136.89...
brucedo...@comcast.net wrote in
news:57**********************************@e39g2000 hsf.googlegroups.co
m:
I have an Access 2003 form bound to a SQL Server table via ODBC.
Often clicking a button on the form has the effect of requerying
the form rather than firing the OnClick event. * Does anyone have
an explanation? *Is this evidence of corruption, or a known side
effect?
What does the code in the OnClick event of the command button do?
--
David W. Fenton * * * * * * * * *http://www.dfenton.com/
usenet at dfenton dot com * *http://www.dfenton.com/DFA/

I've run into something similar, sometimes. If I change the name of some
controls, sometimes the event linked to that control gets "lost" somehow.To
fix, I exit the VBA code and return to form design view. Then I select the
properties window of the failing control. Then I cursor down to the
associated event. Normally the event should say [Event Procedure]. But when
it's "lost", the property is blank. So I click on the ellipsis (...) and
select "code builder". That opens the VBA code and re-establishes the link
to my coded event.
Fred Zuckerman
Thanks, Fred. I've had this happen, too. However, in this case the
code is not disconnected from the control - it's just not firing.
Sep 25 '08 #7

P: n/a
On Sep 23, 8:37*pm, "Rick Brandt" <rickbran...@hotmail.comwrote:
brucedo...@comcast.net wrote:
I have an Access 2003 form bound to a SQL Server table via ODBC.
Often clicking a button on the form has the effect of requerying the
form rather than firing the OnClick event. * Does anyone have an
explanation? *Is this evidence of corruption, or a known side effect?

Never heard of it. Ever. *I suppose that means corruption is possible, but
only some of the time?

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt * at * Hunter * dot * com
This application is corrupt, and I think this form is at the heart of
it. I've decompiled the application per Allan Browne's instructions
and done saveastext/loadfromtext several times. This has reduced
symptoms, but they always come back. One sympton that is always
present is that this form always prompts you to save changes if you
look at its code, whether you made changes or not. I'm thinking of
sending the app to a repair service.

Whether that's causing this behavior is another question. Could it
have something to do with the bound ODBC attached SQL Server table?

(Light bulb goes on)

I believe what's happening is that the Exit event of the combo box for
selecting client number is firing. That requeries the form. It's a
frequently used control.

Doh! Well, thanks for the help, guys. Talking to others to is a
great way to stimulate synapses that are stuck in neutral.
Sep 25 '08 #8

P: n/a
br********@comcast.net wrote in
news:30**********************************@t54g2000 hsg.googlegroups.co
m:
Here's a sample, but this is not the only button for which this
occurs:
Private Sub cmdRebuildClientSProc_Click()
'22)
If Len(Trim(Nz(cmbClient, ""))) = 5 Then
DraftRebuild cmbClient
Else
MsgBox "Please select a valid client"
End If
End Sub
What does DraftRebuild do? That is, post the code for that. If I had
to wager, I'd say that it's likely that whatever code is in the sub
DraftRebuild is causing the record to be saved.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Sep 25 '08 #9

P: n/a
br********@comcast.net wrote in
news:8d**********************************@l64g2000 hse.googlegroups.co
m:
One sympton that is always
present is that this form always prompts you to save changes if
you look at its code, whether you made changes or not. I'm
thinking of sending the app to a repair service.
Er, that's normal since Access 2000, isn't it? Yes, I think it's
annoying, but it's a consequence of the monolithic save model, I
think.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Sep 25 '08 #10

P: n/a
br********@comcast.net wrote in
news:8d**********************************@l64g2000 hse.googlegroups.co
m:
I believe what's happening is that the Exit event of the combo box
for selecting client number is firing. That requeries the form.
It's a frequently used control.
Clicking the button when the focus is on the combo box would cause
the combo box's OnExit to fire. Generally, OnExit is not the event
you want to use, but AfterUpdate.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Sep 25 '08 #11

P: n/a
On Sep 25, 5:16*pm, "David W. Fenton" <XXXuse...@dfenton.com.invalid>
wrote:
brucedo...@comcast.net wrote innews:8d**********************************@l64g20 00hse.googlegroups.co
m:
One sympton that is always
present is that this form always prompts you to save changes if
you look at its code, whether you made changes or not. *I'm
thinking of sending the app to a repair service.

Er, that's normal since Access 2000, isn't it? Yes, I think it's
annoying, but it's a consequence of the monolithic save model, I
think.

--
David W. Fenton * * * * * * * * *http://www.dfenton.com/
usenet at dfenton dot com * *http://www.dfenton.com/DFA/
Simply opening the code module for this form forces a prompt to save,
whether or not anything in the database has been changed. This is not
normal Access behavior.
Sep 26 '08 #12

P: n/a
br********@comcast.net wrote in
news:b9**********************************@26g2000h sk.googlegroups.com
:
On Sep 25, 5:16*pm, "David W. Fenton"
<XXXuse...@dfenton.com.invalidwrote:
>brucedo...@comcast.net wrote
innews:8df73741-bc32-4f39-a581-5ab463f86d09@
l64g2000hse.googlegroups.co
>m:
One sympton that is always
present is that this form always prompts you to save changes if
you look at its code, whether you made changes or not. *I'm
thinking of sending the app to a repair service.

Er, that's normal since Access 2000, isn't it? Yes, I think it's
annoying, but it's a consequence of the monolithic save model, I
think.

Simply opening the code module for this form forces a prompt to
save, whether or not anything in the database has been changed.
This is not normal Access behavior.
That's normal for the Access installations that I've worked in since
Access 2000. I don't like it, but that's the way it works.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Sep 26 '08 #13

P: n/a
On Sep 26, 10:23*am, brucedo...@comcast.net wrote:
On Sep 25, 5:16*pm, "David W. Fenton" <XXXuse...@dfenton.com.invalid>
wrote:
brucedo...@comcast.net wrote innews:8d**********************************@l64g20 00hse.googlegroups.co
m:
One sympton that is always
present is that this form always prompts you to save changes if
you look at its code, whether you made changes or not. *I'm
thinking of sending the app to a repair service.
Er, that's normal since Access 2000, isn't it? Yes, I think it's
annoying, but it's a consequence of the monolithic save model, I
think.
--
David W. Fenton * * * * * * * * *http://www.dfenton.com/
usenet at dfenton dot com * *http://www.dfenton.com/DFA/

Simply opening the code module for this form forces a prompt to save,
whether or not anything in the database has been changed. *This is not
normal Access behavior.
my experience has been;
from database window view , click on a form, click code(toolbar
button), form opens to it's code page, if I do nothing just look then
close the code page then close the form it does not ask to save
changes.

if however, from the database window view, click on a form, click
design view, click on a control and from it's property sheet click on
( ... ) to display the code in any of it's events that has code and
just look at the code, then close the code page, then close the form,
it will ask me to save changes.

so it depends on how you go about getting to the code page, at least,
for me anyways.
Sep 26 '08 #14

P: n/a
On Sep 26, 3:59*pm, bobh <vulca...@yahoo.comwrote:
On Sep 26, 10:23*am, brucedo...@comcast.net wrote:


On Sep 25, 5:16*pm, "David W. Fenton" <XXXuse...@dfenton.com.invalid>
wrote:
brucedo...@comcast.net wrote innews:8d**********************************@l64g20 00hse.googlegroups.co
m:
One sympton that is always
present is that this form always prompts you to save changes if
you look at its code, whether you made changes or not. *I'm
thinking of sending the app to a repair service.
Er, that's normal since Access 2000, isn't it? Yes, I think it's
annoying, but it's a consequence of the monolithic save model, I
think.
--
David W. Fenton * * * * * * * * *http://www.dfenton..com/
usenet at dfenton dot com * *http://www.dfenton.com/DFA/
Simply opening the code module for this form forces a prompt to save,
whether or not anything in the database has been changed. *This is not
normal Access behavior.

my experience has been;
from database window view , click on a form, click code(toolbar
button), form opens to it's code page, if I do nothing just look then
close the code page then close the form it does not ask to save
changes.

if however, from the database window view, click on a form, click
design view, click on a control and from it's property sheet click on
( ... ) to display the code in any of it's events that has code and
just look at the code, then close the code page, then close the form,
it will ask me to save changes.

so it depends on how you go about getting to the code page, at least,
for me anyways.- Hide quoted text -

- Show quoted text -
Thanks, Bob. This form prompts for save even if you view the code
directly from form design, without going through a property sheet.
Sep 26 '08 #15

P: n/a
On Sep 26, 2:53*pm, "David W. Fenton" <XXXuse...@dfenton.com.invalid>
wrote:
brucedo...@comcast.net wrote innews:b9**********************************@26g200 0hsk.googlegroups.com
:


On Sep 25, 5:16*pm, "David W. Fenton"
<XXXuse...@dfenton.com.invalidwrote:
brucedo...@comcast.net wrote
innews:8df73741-bc32-4f39-a581-5ab463f86d09@
l64g2000hse.googlegroups.co
m:
One sympton that is always
present is that this form always prompts you to save changes if
you look at its code, whether you made changes or not. *I'm
thinking of sending the app to a repair service.
Er, that's normal since Access 2000, isn't it? Yes, I think it's
annoying, but it's a consequence of the monolithic save model, I
think.
Simply opening the code module for this form forces a prompt to
save, whether or not anything in the database has been changed.
This is not normal Access behavior.

That's normal for the Access installations that I've worked in since
Access 2000. I don't like it, but that's the way it works.

--
David W. Fenton * * * * * * * * *http://www.dfenton.com/
usenet at dfenton dot com * *http://www.dfenton.com/DFA/- Hide quotedtext -

- Show quoted text -
Opening other forms and viewing the code in in this same application
doesn't cause that behavior. I know - I just confirmed it.
Sep 26 '08 #16

P: n/a
Opening other forms and viewing the code in in this same application
doesn't cause that behavior. I know - I just confirmed it.
You mean ,say you have 10 forms and only one of them is asking saving
and the rest 9 don't ?
That is rather strange though because normally all of them should
follow Bob's way.
Sep 26 '08 #17

P: n/a
br********@comcast.net wrote in
news:a6**********************************@c65g2000 hsa.googlegroups.co
m:
Opening other forms and viewing the code in in this same
application doesn't cause that behavior. I know - I just confirmed
it.
I see it often enough when I've made no changes at all that I just
don't see it as an issue. Perhaps it's not every time, but it's
often enough that I don't see it as something to worry about.

Why are *you* worrying about it?

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Sep 27 '08 #18

P: n/a
br********@comcast.net wrote in
news:65**********************************@d77g2000 hsb.googlegroups.co
m:
This form prompts for save even if you view the code
directly from form design, without going through a property sheet.
Why is this something you're worrying about?

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Sep 27 '08 #19

P: n/a
On Sep 27, 6:28*pm, "David W. Fenton" <XXXuse...@dfenton.com.invalid>
wrote:
brucedo...@comcast.net wrote innews:a6**********************************@c65g20 00hsa.googlegroups.co
m:
Opening other forms and viewing the code in in this same
application doesn't cause that behavior. I know - I just confirmed
it.

I see it often enough when I've made no changes at all that I just
don't see it as an issue. Perhaps it's not every time, but it's
often enough that I don't see it as something to worry about.

Why are *you* worrying about it?

--
David W. Fenton * * * * * * * * *http://www.dfenton.com/
usenet at dfenton dot com * *http://www.dfenton.com/DFA/
The form shows other evidence of corruption, such as having crashed
Access when I tried to save it under another name.
Sep 29 '08 #20

P: n/a
br********@comcast.net wrote in
news:ff**********************************@f63g2000 hsf.googlegroups.co
m:
On Sep 27, 6:28*pm, "David W. Fenton"
<XXXuse...@dfenton.com.invalidwrote:
>brucedo...@comcast.net wrote
innews:a6731e6b-caa0-466e-8b33-d0e556eca617@
c65g2000hsa.googlegroups.co
>m:
Opening other forms and viewing the code in in this same
application doesn't cause that behavior. I know - I just
confirmed it.

I see it often enough when I've made no changes at all that I
just don't see it as an issue. Perhaps it's not every time, but
it's often enough that I don't see it as something to worry
about.

Why are *you* worrying about it?

The form shows other evidence of corruption, such as having
crashed Access when I tried to save it under another name.
Have you made sure there's not a data problem? Last week I spent a
couple of hours trying to rebuild an old form that I thought was
corrupted, and when I got to the point of adding on some bound
subforms, that was when it started crashing. The cause was that I'd
mislinked the underlying data tables to the wrong back end file
(don't ask -- legacy app dating to 1996!), and when that was fixed,
the form stopped crashing.

If you've already rebuilt the form from
Application.SaveAsText/.LoadFromText, and done it all in a fresh MDB
and you're still having the problem, then I would suggest it's *not*
caused by corruption at all, but by some other cause.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Sep 29 '08 #21

P: n/a
On Sep 29, 6:13*pm, "David W. Fenton" <XXXuse...@dfenton.com.invalid>
wrote:
brucedo...@comcast.net wrote innews:ff**********************************@f63g20 00hsf.googlegroups.co
m:


On Sep 27, 6:28*pm, "David W. Fenton"
<XXXuse...@dfenton.com.invalidwrote:
brucedo...@comcast.net wrote
innews:a6731e6b-caa0-466e-8b33-d0e556eca617@
c65g2000hsa.googlegroups.co
m:
Opening other forms and viewing the code in in this same
application doesn't cause that behavior. I know - I just
confirmed it.
I see it often enough when I've made no changes at all that I
just don't see it as an issue. Perhaps it's not every time, but
it's often enough that I don't see it as something to worry
about.
Why are *you* worrying about it?
The form shows other evidence of corruption, such as having
crashed Access when I tried to save it under another name.

Have you made sure there's not a data problem? Last week I spent a
couple of hours trying to rebuild an old form that I thought was
corrupted, and when I got to the point of adding on some bound
subforms, that was when it started crashing. The cause was that I'd
mislinked the underlying data tables to the wrong back end file
(don't ask -- legacy app dating to 1996!), and when that was fixed,
the form stopped crashing.

If you've already rebuilt the form from
Application.SaveAsText/.LoadFromText, and done it all in a fresh MDB
and you're still having the problem, then I would suggest it's *not*
caused by corruption at all, but by some other cause.

--
David W. Fenton * * * * * * * * *http://www.dfenton.com/
usenet at dfenton dot com * *http://www.dfenton.com/DFA/- Hide quotedtext -

- Show quoted text -
My boss wonders the same thing. However, there have been so many
persistent symptoms of corruption, such as the application opening to
a code window after compact/repair; Access crashes; the aforesaid
prompts to save objects that haven't been touched; that I remain
concerned. The system has had a hard life. The code was not
compiled when I arrived, and Auto Rename and Compile On Demand were
both turned on. Also, performing corruption repair steps does
ameliorate the symptoms when they get out of hand.

I do wonder now if the On Exit routine for that combo box could be
causing corruption. Worth a look. Thank you for your suggestions.
Oct 1 '08 #22

This discussion thread is closed

Replies have been disabled for this discussion.