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

Button Event Handler

P: n/a
I’ve come across an unusual situation tonight, so I’m going to see if anyone
can give me an explanation for what could be going on here.

I created a new form based on instructions from a Microsoft Press book.
Rather than create the entire form (visually), I decided to copy and paste
all the controls from the training sample to my sample. Then, after words, I
entered all of the form’s code. Now, there are two buttons on the form. In
the form’s code module I found an event for one of the buttons. Anyway, I ran
the project anyway without adding any code to the btnClose button. But, when
I clicked on the close button the form closed. Now, this puzzles the heck out
of me. How can my form close when the form’s event modules do not include a
click event or any other event associated with the close button? If fact,
there’s no CLOSE command anywhere in the form’s code at all.

Does anyone have an explanation why something like this could happen?

I know this you might think this can’t be, but its happening and it makes no
sense to me. I’m assuming there must be a way to embed code in a control that
is not visible in the code editor?

I also set a breakpoint on every single line of code in the form and still,
the close button closes the form. Plus, I added an event handler to the click
event to display a message and it worked, but still closed the form. This
makes no sense to me and how can this be possible.

Oct 20 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On Oct 19, 10:55 pm, Greg <AccessVBA...@newsgroups.nospamwrote:
I've come across an unusual situation tonight, so I'm going to see if anyone
can give me an explanation for what could be going on here.

I created a new form based on instructions from a Microsoft Press book.
Rather than create the entire form (visually), I decided to copy and paste
all the controls from the training sample to my sample. Then, after words, I
entered all of the form's code. Now, there are two buttons on the form. In
the form's code module I found an event for one of the buttons. Anyway, I ran
the project anyway without adding any code to the btnClose button. But, when
I clicked on the close button the form closed. Now, this puzzles the heck out
of me. How can my form close when the form's event modules do not include a
click event or any other event associated with the close button? If fact,
there's no CLOSE command anywhere in the form's code at all.

Does anyone have an explanation why something like this could happen?

I know this you might think this can't be, but its happening and it makes no
sense to me. I'm assuming there must be a way to embed code in a control that
is not visible in the code editor?

I also set a breakpoint on every single line of code in the form and still,
the close button closes the form. Plus, I added an event handler to the click
event to display a message and it worked, but still closed the form. This
makes no sense to me and how can this be possible.
Hmmm... My guess is that the from is shown using form.showdialog, and
the close buttons DialogResult property is set?

Am I close?

--
Tom Shelton

Oct 20 '07 #2

P: n/a

default button and dialog result property`s i use this handy feature to
let my user close a dialog with a enter strike

hth

Michel

"Greg" <Ac**********@newsgroups.nospamschreef in bericht
news:70**********************************@microsof t.com...
I've come across an unusual situation tonight, so I'm going to see if
anyone
can give me an explanation for what could be going on here.

I created a new form based on instructions from a Microsoft Press book.
Rather than create the entire form (visually), I decided to copy and paste
all the controls from the training sample to my sample. Then, after words,
I
entered all of the form's code. Now, there are two buttons on the form. In
the form's code module I found an event for one of the buttons. Anyway, I
ran
the project anyway without adding any code to the btnClose button. But,
when
I clicked on the close button the form closed. Now, this puzzles the heck
out
of me. How can my form close when the form's event modules do not include
a
click event or any other event associated with the close button? If fact,
there's no CLOSE command anywhere in the form's code at all.

Does anyone have an explanation why something like this could happen?

I know this you might think this can't be, but its happening and it makes
no
sense to me. I'm assuming there must be a way to embed code in a control
that
is not visible in the code editor?

I also set a breakpoint on every single line of code in the form and
still,
the close button closes the form. Plus, I added an event handler to the
click
event to display a message and it worked, but still closed the form. This
makes no sense to me and how can this be possible.

Oct 20 '07 #3

P: n/a
"Greg" <Ac**********@newsgroups.nospamschrieb:
I created a new form based on instructions from a Microsoft Press book.
Rather than create the entire form (visually), I decided to copy and paste
all the controls from the training sample to my sample. Then, after words,
I
entered all of the form’s code. Now, there are two buttons on the form. In
the form’s code module I found an event for one of the buttons. Anyway, I
ran
the project anyway without adding any code to the btnClose button. But,
when
I clicked on the close button the form closed.
Make sure there is no 'DialogResult' assigned to the button's 'DialogResult'
property. You can check this in the button's property window.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Oct 20 '07 #4

P: n/a
Ok, now that makes a little sense then. I can also see now that there is a
DialogResult property associated with a buttonc control. It seems that if I
set this property to Cancel, it will always close the form, regardless of how
it was opened. Plus, I can just use this property instead of creating a Click
event with me.close in it. Acutally, it seems that I can use any DialogResult
option to close the form.

I can see were this will be a very useful tool.

Thankis everyone.

Greg

"Tom Shelton" wrote:
On Oct 19, 10:55 pm, Greg <AccessVBA...@newsgroups.nospamwrote:
I've come across an unusual situation tonight, so I'm going to see if anyone
can give me an explanation for what could be going on here.

I created a new form based on instructions from a Microsoft Press book.
Rather than create the entire form (visually), I decided to copy and paste
all the controls from the training sample to my sample. Then, after words, I
entered all of the form's code. Now, there are two buttons on the form. In
the form's code module I found an event for one of the buttons. Anyway, I ran
the project anyway without adding any code to the btnClose button. But, when
I clicked on the close button the form closed. Now, this puzzles the heck out
of me. How can my form close when the form's event modules do not include a
click event or any other event associated with the close button? If fact,
there's no CLOSE command anywhere in the form's code at all.

Does anyone have an explanation why something like this could happen?

I know this you might think this can't be, but its happening and it makes no
sense to me. I'm assuming there must be a way to embed code in a control that
is not visible in the code editor?

I also set a breakpoint on every single line of code in the form and still,
the close button closes the form. Plus, I added an event handler to the click
event to display a message and it worked, but still closed the form. This
makes no sense to me and how can this be possible.

Hmmm... My guess is that the from is shown using form.showdialog, and
the close buttons DialogResult property is set?

Am I close?

--
Tom Shelton

Oct 20 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.