From: Dennis Rose on
Using VB5.

With MDI and MDI child forms, how do I prevent a user from closing(by
clicking the "X") on either the MDI or MDI child form while a Edit or a
AddNew is in progress(ie. before an Update or CancelUpdate)?

I tried to trap the closing and use CancelUpdate using "Form_QueryUnload"
but the recordset had already been updated with the partial changes I had
made prior to chicling Close.

Help!!
From: Dennis Rose on


"Dennis Rose" wrote:

> Using VB5.
>
> With MDI and MDI child forms, how do I prevent a user from closing(by
> clicking the "X") on either the MDI or MDI child form while a Edit or a
> AddNew is in progress(ie. before an Update or CancelUpdate)?
>
> I tried to trap the closing and use CancelUpdate using "Form_QueryUnload"
> but the recordset had already been updated with the partial changes I had
> made prior to chicling Close.
>
> Help!!


Come on all you experts! I need help here.
From: senn on

"Dennis Rose" <DennisRose(a)discussions.microsoft.com> skrev i meddelelsen
news:2D70E538-EA80-4C26-8651-9D1489A69EE1(a)microsoft.com...
> Using VB5.
>
> With MDI and MDI child forms, how do I prevent a user from closing(by
> clicking the "X") on either the MDI or MDI child form while a Edit or a
> AddNew is in progress(ie. before an Update or CancelUpdate)?
>
> I tried to trap the closing and use CancelUpdate using "Form_QueryUnload"
> but the recordset had already been updated with the partial changes I had
> made prior to chicling Close.
>
> Help!!

Remove the closing-tab from the form. Done in the
property window.
I think you have better luck posting to
comp.lang.basic.visual.misc
Many gone there by now. Besides, most is
less active on newsgroups in week-ends.
/se

From: Wolfgang Enzinger on
On Fri, 4 Jun 2010 14:00:12 -0700, Dennis Rose
<DennisRose(a)discussions.microsoft.com> wrote:

>> Using VB5.
>>
>> With MDI and MDI child forms, how do I prevent a user from closing(by
>> clicking the "X") on either the MDI or MDI child form while a Edit or a
>> AddNew is in progress(ie. before an Update or CancelUpdate)?
>>
>> I tried to trap the closing and use CancelUpdate using "Form_QueryUnload"
>> but the recordset had already been updated with the partial changes I had
>> made prior to chicling Close.
>>
>> Help!!
>
>
>Come on all you experts! I need help here.

Assuming you're talking about a DAO database, here's a pointer:

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Dim db As DAO.Database, rs As DAO.Recordset
For Each db In DBEngine.Workspaces(0).Databases
For Each rs In db.Recordsets
If rs.EditMode <> dbEditNone Then
MsgBox "AddNew or Edit in progress; cannot terminate", vbExclamation
Cancel = True
Exit Sub
End If
Next
Next
End Sub

Not tested, but might give you an idea.

hth