From: mls via AccessMonster.com on
I have 2 buttons on my form. Button1 to import the data and Button2 to upload
to database. I want user to click first on button1 and then next on button2
before closing the form. What form event I should use to prevent user from
closing the form with out clicking on 2nd button?


Thanks

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access/201004/1

From: Jeanette Cunningham on
You can use the Unload event. You can prevent the form closing by setting
Cancel = True in the unload event.
You will need a way to notify the form that uploading has finished.
You can put an unbound checkbox on the form, set its default value to True.

When your upload code has completed, you can set the checkbox to False.

In the unload event, you can go
Cancel = Me.ChkName = True

Replace ChkName with the name of your check box.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia



"mls via AccessMonster.com" <u55943(a)uwe> wrote in message
news:a6c76d7d72623(a)uwe...
>I have 2 buttons on my form. Button1 to import the data and Button2 to
>upload
> to database. I want user to click first on button1 and then next on
> button2
> before closing the form. What form event I should use to prevent user from
> closing the form with out clicking on 2nd button?
>
>
> Thanks
>
> --
> Message posted via AccessMonster.com
> http://www.accessmonster.com/Uwe/Forums.aspx/access/201004/1
>


From: mls via AccessMonster.com on
Hi Jeanette, This solutions works. How ever I have a strange situation: My
code is in testing stage and I placed this code( Cancel = True ) in the
form_unload event and after the Inserting into database( Cancel = False).
My problem is: When I clicked on the upload button it failed because of the
keyviolation ( Purposefully I created this to stop duplication) . Now I could
not come out of my database no matter how I tried.
I have a "close form" button and when I clicked on that, it says "close
action was cancelled".
Even I main database close action is not working. How can I come out?


Jeanette Cunningham wrote:
>You can use the Unload event. You can prevent the form closing by setting
>Cancel = True in the unload event.
>You will need a way to notify the form that uploading has finished.
>You can put an unbound checkbox on the form, set its default value to True.
>
>When your upload code has completed, you can set the checkbox to False.
>
>In the unload event, you can go
>Cancel = Me.ChkName = True
>
>Replace ChkName with the name of your check box.
>
>Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
>
>>I have 2 buttons on my form. Button1 to import the data and Button2 to
>>upload
>[quoted text clipped - 4 lines]
>>
>> Thanks

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access/201004/1

From: Hans Up on
mls via AccessMonster.com wrote:
> Hi Jeanette, This solutions works. How ever I have a strange situation: My
> code is in testing stage and I placed this code( Cancel = True ) in the
> form_unload event and after the Inserting into database( Cancel = False).
> My problem is: When I clicked on the upload button it failed because of the
> keyviolation ( Purposefully I created this to stop duplication) . Now I could
> not come out of my database no matter how I tried.
> I have a "close form" button and when I clicked on that, it says "close
> action was cancelled".
> Even I main database close action is not working. How can I come out?

Switch to design view for your form, then disable your Cancel = True
statement by inserting a single quote at the start of the line.
From: Jeanette Cunningham on
You can also change the Cancel = True from any other form like this:
Change the status of the checkbox to false, then you will be able to close
the form.

Forms!FormName.ChkName = False

Note: replace the object names to suit your database.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


"mls via AccessMonster.com" <u55943(a)uwe> wrote in message
news:a6dd96bb48724(a)uwe...
> Hi Jeanette, This solutions works. How ever I have a strange situation: My
> code is in testing stage and I placed this code( Cancel = True ) in the
> form_unload event and after the Inserting into database( Cancel = False).
> My problem is: When I clicked on the upload button it failed because of
> the
> keyviolation ( Purposefully I created this to stop duplication) . Now I
> could
> not come out of my database no matter how I tried.
> I have a "close form" button and when I clicked on that, it says "close
> action was cancelled".
> Even I main database close action is not working. How can I come out?
>
>
> Jeanette Cunningham wrote:
>>You can use the Unload event. You can prevent the form closing by setting
>>Cancel = True in the unload event.
>>You will need a way to notify the form that uploading has finished.
>>You can put an unbound checkbox on the form, set its default value to
>>True.
>>
>>When your upload code has completed, you can set the checkbox to False.
>>
>>In the unload event, you can go
>>Cancel = Me.ChkName = True
>>
>>Replace ChkName with the name of your check box.
>>
>>Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
>>
>>>I have 2 buttons on my form. Button1 to import the data and Button2 to
>>>upload
>>[quoted text clipped - 4 lines]
>>>
>>> Thanks
>
> --
> Message posted via AccessMonster.com
> http://www.accessmonster.com/Uwe/Forums.aspx/access/201004/1
>