473,387 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Can I control how user exits access?

Hi

I have a problem with a database where certain users are closing access (by
clicking on the X in top right-hand corner) instead of using a command
button before they fill in all relevant fields.

Q. Is there a way of not allowing them to exist access using the this way
and use the command button?

Thanks in Advance
David Sullivan
Nov 13 '05 #1
6 1769
HJ
Yes, you can. On a form you can use the Unload event to prevent it from
closing, unless you want it to. I use it myself on a form that remains open
at all times and that can only be closed with a command button.

Private Sub Form_Unload(Cancel As Integer)

.... do anything...

Cancel = True

.... do anything...

End Sub

Regards,

HJ

"David Sullivan" <da******@indigo.ie> wrote in message
news:_V*******************@news.indigo.ie...
Hi

I have a problem with a database where certain users are closing access (by clicking on the X in top right-hand corner) instead of using a command
button before they fill in all relevant fields.

Q. Is there a way of not allowing them to exist access using the this way
and use the command button?

Thanks in Advance
David Sullivan

Nov 13 '05 #2
HJ wrote:
Yes, you can. On a form you can use the Unload event to prevent it from
closing, unless you want it to. I use it myself on a form that remains open
at all times and that can only be closed with a command button.

Private Sub Form_Unload(Cancel As Integer)

... do anything...

Cancel = True

... do anything...

End Sub

Regards,

HJ


It works for a record that exists. It will not save new recs. It's too
bad MS didn't put in a trap that could exist prior to the BeforeUpdate
that could trap for it.
Nov 13 '05 #3
HJ

"Salad" <oi*@vinegar.com> wrote in message
news:GW****************@newsread3.news.pas.earthli nk.net...

It works for a record that exists. It will not save new recs. It's too
bad MS didn't put in a trap that could exist prior to the BeforeUpdate
that could trap for it.


It does save new records, because when you close the form (and the
application) the newly entered data is saved; Access has been designed that
way.

But you may need to program some record handling for that Unload event,
based on your needs. E.g. by using a global or public variable that is set
when you edit a record, or by having the user enter a minimum set of data in
the new record (and check that with a procedure that results in True or
False), etc.
Nov 13 '05 #4
HJ wrote:
"Salad" <oi*@vinegar.com> wrote in message
news:GW****************@newsread3.news.pas.earthli nk.net...
It works for a record that exists. It will not save new recs. It's too
bad MS didn't put in a trap that could exist prior to the BeforeUpdate
that could trap for it.

It does save new records, because when you close the form (and the
application) the newly entered data is saved; Access has been designed that
way.

But you may need to program some record handling for that Unload event,
based on your needs. E.g. by using a global or public variable that is set
when you edit a record, or by having the user enter a minimum set of data in
the new record (and check that with a procedure that results in True or
False), etc.


Hmmmm....I know there is a big flaw, as far as I'm concerned, with the
Unload event. It's possible that the flaw is that the form's
BeforeUpdate event can't be canceled. Something like that. It's a pain
in the butt and there is no known solution for it that I'm aware of. It
might be OK if there is no before/after update event for the form.

I think its BeforeUpdate. If you attempt to cancel because an error
exists or some field is missing data or something like that...it might
be with a new record...the unload cancels and all data for the new
record is lost. Maybe it does the same for editting a current record.

It's almost as if MS forgot about the BeforeUpdate event.

Nov 13 '05 #5
David Sullivan wrote:
I have a problem with a database where certain users are closing access (by
clicking on the X in top right-hand corner) instead of using a command
button before they fill in all relevant fields.


Here's one method.

Create a form and call it something simple - I use "frmV" and often use
it to store variables in controls instead of relying on global
variables. In the unload event of this form, have the procedures that
you want to make sure happen when the database app is closed. The trick
is, you want this form to open *hidden* when the database is opened.

There are a couple of ways to accomplish this. I will sometimes have a
splash form that appears on opening of the mdb or simply a starting form
with cancel = true in the on open event.

If you use the latter, put in a

DoCmd.OpenForm "frmV", acNormal, , , , acHidden

and then your cancel = true. If you use a splash form that your users
bring up whenever they click on About This App on a menu item or
something, you can check to see if frm HIdden is open in the on open
event of the form (air code):

Private Sub Form_Open(Cancel As Integer)

dim f as Access.form
dim booFound as boolean

boofound = false

for each f in access.forms

if f.name = "frmV" then 'frmOpen is found and is already open

boofound = true

exit for

end if

Next

if boofound = false then DoCmd.OpenForm "frmV", acNormal, , , , acHidden

End Sub

--
Tim
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "What's UP, Dittoooooo?" - Ditto
Nov 13 '05 #6
Correction:

Tim Marshall wrote:
if f.name = "frmV" then 'frmOpen is found and is already open


Should be:

if f.name = "frmV" then 'frmV is found and is already open

--
Tim
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "What's UP, Dittoooooo?" - Ditto
Nov 13 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Lucvdv | last post by:
To avoid a temporarily frozen user interface, I'm using a separate thread to fill a list with items found in a database (there can be from a few up to about 1000 or 1500 items). There seems to...
4
by: Keith H. | last post by:
I found a post on this problem from 2004, but no one at that time replied to it- I'm hoping to have better luck than the original author! As the subject states, I'm running into a problem where...
7
by: Buck Rogers | last post by:
Hi all! Newbie here. Below is an example from Teach Yourself C in 21 Days. My apologies if it is a bit long. What I don't understand is how the "get_data" function can call the...
15
by: eladla | last post by:
Hi! I am creating a composite control the does some of it`s own data access. I want to display a progress bar between the time the page is loaded and the control place holder is displayed and...
0
by: Petra | last post by:
Hi! I don't know how to handle the following problem: When a User clicks on the detail view of an item, I lock the item in the database. If the user exits with clicking the cancel or ok button...
17
by: teddysnips | last post by:
One of my clients has asked me to make a change to one of their Access applications. The application is a Front End/Back End standard app. I didn't develop it, but looking at it tells me that...
5
by: gregarican | last post by:
There is a C# CTI app I'm working on using Visual Studio 2005 at revision level 8.0.50727-7600. I need a couple of Windows Form Button controls to emulate line buttons on a telephone. So I went to...
3
by: EManning | last post by:
I''m having problems getting a form to open while going from one tab to another. I have a tab control: one tab for counties and one tab for cities. Both tabs have multi-select listboxes. If...
19
by: emanning | last post by:
Using Access 2003 and using a form that's mostly bound. I need a way to tell if user-1 is on the record when user-2 tries to open the same record, w/o waiting for the user-1 to save the record...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.