Undo function 
Author Message
 Undo function

This should be simple, but for some reason, it's not working for me.
I have a combo box with a list of account reps...I did a union query to
include a "Modify".
If a user choose "Modify", I want the combo box to be undone and then
open another form.

In the event procedure of the AccountRep beforeupdate (or on change), i
have the following function:

If Me!AccountRep = "Modify" Then
    Me!AccountRep.Undo
    Do.cmd OpenForm "frmAccountRep"
Else
End If

The combo box doesn't undo.  I tried it in the beforeupdate and on
change.  When I substitute the Me!AccountRep.Undo for SendKeys "{ESC}",
it works, but it undoes all the changes in the form.  I just want to
undo that combo box.

I even tried writing out the form name, instead of "Me!"...that still
didnt work.

What am I doing wrong?

Thanks.

Ngan



Tue, 10 Sep 2002 03:00:00 GMT  
 Undo function
Just guessing, but when you have this code in the BeforeUpdate event, do you
also set the Cancel parameter to True?  I'm thinking maybe you have to.

--

Dirk Goldgar
(remove NOSPAM from reply address)


Quote:
> This should be simple, but for some reason, it's not working for me.
> I have a combo box with a list of account reps...I did a union query to
> include a "Modify".
> If a user choose "Modify", I want the combo box to be undone and then
> open another form.

> In the event procedure of the AccountRep beforeupdate (or on change), i
> have the following function:

> If Me!AccountRep = "Modify" Then
>     Me!AccountRep.Undo
>     Do.cmd OpenForm "frmAccountRep"
> Else
> End If

> The combo box doesn't undo.  I tried it in the beforeupdate and on
> change.  When I substitute the Me!AccountRep.Undo for SendKeys "{ESC}",
> it works, but it undoes all the changes in the form.  I just want to
> undo that combo box.

> I even tried writing out the form name, instead of "Me!"...that still
> didnt work.

> What am I doing wrong?

> Thanks.

> Ngan



Tue, 10 Sep 2002 03:00:00 GMT  
 Undo function
where do you set the parameter? the code is:

Private Sub AccountRep_BeforeUpdate(Cancel As Integer)

If Me!AccountRep = "Modify" Then
   Me!AccountRep.Undo
   DoCmd.OpenForm "frmAccountRep"
Else
End If

End Sub

Quote:

> Just guessing, but when you have this code in the BeforeUpdate event, do you
> also set the Cancel parameter to True?  I'm thinking maybe you have to.

> --

> Dirk Goldgar
> (remove NOSPAM from reply address)



> > This should be simple, but for some reason, it's not working for me.
> > I have a combo box with a list of account reps...I did a union query to
> > include a "Modify".
> > If a user choose "Modify", I want the combo box to be undone and then
> > open another form.

> > In the event procedure of the AccountRep beforeupdate (or on change), i
> > have the following function:

> > If Me!AccountRep = "Modify" Then
> >     Me!AccountRep.Undo
> >     Do.cmd OpenForm "frmAccountRep"
> > Else
> > End If

> > The combo box doesn't undo.  I tried it in the beforeupdate and on
> > change.  When I substitute the Me!AccountRep.Undo for SendKeys "{ESC}",
> > it works, but it undoes all the changes in the form.  I just want to
> > undo that combo box.

> > I even tried writing out the form name, instead of "Me!"...that still
> > didnt work.

> > What am I doing wrong?

> > Thanks.

> > Ngan



Tue, 10 Sep 2002 03:00:00 GMT  
 Undo function
You would do it like this:

    Private Sub AccountRep_BeforeUpdate(Cancel As Integer)

        If Me!AccountRep = "Modify" Then
            Me!AccountRep.Undo
            Cancel = True
            DoCmd.OpenForm "frmAccountRep
        Else
        End If

    End Sub

I still don't know for sure that this will solve your problem with Undo, but
it should stop the control from being updated.
--

Dirk Goldgar
(remove NOSPAM from reply address)


Quote:
> where do you set the parameter? the code is:

> Private Sub AccountRep_BeforeUpdate(Cancel As Integer)

> If Me!AccountRep = "Modify" Then
>    Me!AccountRep.Undo
>    DoCmd.OpenForm "frmAccountRep"
> Else
> End If

> End Sub


> > Just guessing, but when you have this code in the BeforeUpdate event, do
you
> > also set the Cancel parameter to True?  I'm thinking maybe you have to.

> > --

> > Dirk Goldgar
> > (remove NOSPAM from reply address)



> > > This should be simple, but for some reason, it's not working for me.
> > > I have a combo box with a list of account reps...I did a union query
to
> > > include a "Modify".
> > > If a user choose "Modify", I want the combo box to be undone and then
> > > open another form.

> > > In the event procedure of the AccountRep beforeupdate (or on change),
i
> > > have the following function:

> > > If Me!AccountRep = "Modify" Then
> > >     Me!AccountRep.Undo
> > >     Do.cmd OpenForm "frmAccountRep"
> > > Else
> > > End If

> > > The combo box doesn't undo.  I tried it in the beforeupdate and on
> > > change.  When I substitute the Me!AccountRep.Undo for SendKeys
"{ESC}",
> > > it works, but it undoes all the changes in the form.  I just want to
> > > undo that combo box.

> > > I even tried writing out the form name, instead of "Me!"...that still
> > > didnt work.

> > > What am I doing wrong?

> > > Thanks.

> > > Ngan



Tue, 10 Sep 2002 03:00:00 GMT  
 Undo function
I guessed that's what you meant...it didn't change it back to the original.  i
must be missing something.

Thanks anyways...I found a workaround and made a modify button :)

Quote:

> You would do it like this:

>     Private Sub AccountRep_BeforeUpdate(Cancel As Integer)

>         If Me!AccountRep = "Modify" Then
>             Me!AccountRep.Undo
>             Cancel = True
>             DoCmd.OpenForm "frmAccountRep
>         Else
>         End If

>     End Sub

> I still don't know for sure that this will solve your problem with Undo, but
> it should stop the control from being updated.
> --

> Dirk Goldgar
> (remove NOSPAM from reply address)



> > where do you set the parameter? the code is:

> > Private Sub AccountRep_BeforeUpdate(Cancel As Integer)

> > If Me!AccountRep = "Modify" Then
> >    Me!AccountRep.Undo
> >    DoCmd.OpenForm "frmAccountRep"
> > Else
> > End If

> > End Sub


> > > Just guessing, but when you have this code in the BeforeUpdate event, do
> you
> > > also set the Cancel parameter to True?  I'm thinking maybe you have to.

> > > --

> > > Dirk Goldgar
> > > (remove NOSPAM from reply address)



> > > > This should be simple, but for some reason, it's not working for me.
> > > > I have a combo box with a list of account reps...I did a union query
> to
> > > > include a "Modify".
> > > > If a user choose "Modify", I want the combo box to be undone and then
> > > > open another form.

> > > > In the event procedure of the AccountRep beforeupdate (or on change),
> i
> > > > have the following function:

> > > > If Me!AccountRep = "Modify" Then
> > > >     Me!AccountRep.Undo
> > > >     Do.cmd OpenForm "frmAccountRep"
> > > > Else
> > > > End If

> > > > The combo box doesn't undo.  I tried it in the beforeupdate and on
> > > > change.  When I substitute the Me!AccountRep.Undo for SendKeys
> "{ESC}",
> > > > it works, but it undoes all the changes in the form.  I just want to
> > > > undo that combo box.

> > > > I even tried writing out the form name, instead of "Me!"...that still
> > > > didnt work.

> > > > What am I doing wrong?

> > > > Thanks.

> > > > Ngan



Tue, 10 Sep 2002 03:00:00 GMT  
 Undo function
Perhaps if you requery the control after the undo, it will show up.  Many
times, in coding behind forms, we make changes that we don't redisplay.

I don't know if that applies to your case, but I'd be inclined to put a
requery of the control after I go through with the undo.

-Beau



Tue, 08 Oct 2002 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Undo function

2. Undo functions in VB

3. UNDO Function in Excel Macro by Using VBA

4. Text Are UNDO function

5. Creating the undo function

6. Implementing an UNDO function

7. Custom undo-function

8. Undo function

9. Selective Undo from the Undo List

10. Undo & Redo Functions under Vb 4.0

11. Program Undo

12. Undo

 

 
Powered by phpBB® Forum Software