How to detect that user click on close button (x)

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
How to detect that user click on the close button (button with icon of x)
on a running form?

Actually, I want to know how the form closed, by executing "DoCmd.close
acform, formname" or by clicking on close button.

Thanks
Tran Hong Quang
 
Tran Hong Quang said:
Hi,
How to detect that user click on the close button (button with icon of x)
on a running form?

Actually, I want to know how the form closed, by executing "DoCmd.close
acform, formname" or by clicking on close button.

The code (behind a button I assume) that uses DoCmd.Close could first set a
variable value. Then the Close event of the form can test that variable. If it
is set, then the user used your button, otherwise they used the [X].
 
Hi Rick Brandt,
But the close button (icon of x) is default button of form, not my button.
So that I can't/don't know how to trap the user-action like you mention.

Regards
Tran Hong Quang

Rick Brandt said:
Tran Hong Quang said:
Hi,
How to detect that user click on the close button (button with icon of x)
on a running form?

Actually, I want to know how the form closed, by executing "DoCmd.close
acform, formname" or by clicking on close button.

The code (behind a button I assume) that uses DoCmd.Close could first set a
variable value. Then the Close event of the form can test that variable. If it
is set, then the user used your button, otherwise they used the [X].
 
Hi,
As Mr. Rick said, you can have a variable or field in your
form and assign a value to it onclick of your close button
(Not X). Like:

variable = "True"
DoCmd.close acform, formname


If you see the variable falue later as true it means the
user is used ur command button to close the form. You can
add Onclose of this form another code to assing
value "False"



-----Original Message-----
Hi Rick Brandt,
But the close button (icon of x) is default button of form, not my button.
So that I can't/don't know how to trap the user-action like you mention.

Regards
Tran Hong Quang

Rick Brandt said:
Hi,
How to detect that user click on the close button (button with icon of x)
on a running form?

Actually, I want to know how the form closed, by executing "DoCmd.close
acform, formname" or by clicking on close button.

The code (behind a button I assume) that uses DoCmd.Close could first set a
variable value. Then the Close event of the form can test that variable. If it
is set, then the user used your button, otherwise they used the [X].
.
 
Hi,
I don't have another close button on the form.

User can execute "DoCmd.Close acForm, formname" from outside. I means from
other form, public function, macro, or click on close button of the main Ms
Access.

How to recognize that user explicitly and directly click on default close
button of the form or the form is commanded to close by other way.

Regards
Tran Hong Quang

manchery said:
Hi,
As Mr. Rick said, you can have a variable or field in your
form and assign a value to it onclick of your close button
(Not X). Like:

variable = "True"
DoCmd.close acform, formname


If you see the variable falue later as true it means the
user is used ur command button to close the form. You can
add Onclose of this form another code to assing
value "False"



-----Original Message-----
Hi Rick Brandt,
But the close button (icon of x) is default button of form, not my button.
So that I can't/don't know how to trap the user-action like you mention.

Regards
Tran Hong Quang

Rick Brandt said:
news:16CAFE22-107C-4607-AC8E- (e-mail address removed)...
Hi,
How to detect that user click on the close button (button with icon of x)
on a running form?

Actually, I want to know how the form closed, by executing "DoCmd.close
acform, formname" or by clicking on close button.

The code (behind a button I assume) that uses DoCmd.Close could first set a
variable value. Then the Close event of the form can test that variable. If it
is set, then the user used your button, otherwise they used the [X].
.
 
Tran Hong Quang said:
Hi,
I don't have another close button on the form.

User can execute "DoCmd.Close acForm, formname" from outside. I means from
other form, public function, macro, or click on close button of the main Ms
Access.

How to recognize that user explicitly and directly click on default close
button of the form or the form is commanded to close by other way.

There is no way to do that that I know of.
 
Hi,
Why don't you disable that (X) default close button and
change your forms property Modal = yes and popup = yes. If
you do this then users can close forms with the buttons
(command buttons) you provided in the form.

I hope this will work,,,, Good Luck...

manchery
 
Back
Top