How do I "regret" change to a combo box

  • Thread starter Thread starter Claire
  • Start date Start date
C

Claire

I have a combo box linked to a control source.

When I pick a new value from the drop down list, the
record is updated.

I would like to be able to "regret" the change - i.e.
before update be asked "do you want to update? - yes / no"

On no I would like to undo the change.

How is that done?
 
Create a BeforeUpdate Event for the combo:

If MsgBox("Do you want to update?", vbQuestion + vbYesNo) = vbNo Then
Cancel = True
Me.fSubject.Undo
End If
 
Well I had that except for the cancel = true - and it
doesn't work in my form...?

what is Cancel? Do I have to make a special declare to
make it work?

Claire
-----Original Message-----
Create a BeforeUpdate Event for the combo:

If MsgBox("Do you want to update?", vbQuestion + vbYesNo) = vbNo Then
Cancel = True
Me.fSubject.Undo
End If


--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

I have a combo box linked to a control source.

When I pick a new value from the drop down list, the
record is updated.

I would like to be able to "regret" the change - i.e.
before update be asked "do you want to update? - yes / no"

On no I would like to undo the change.

How is that done?
.
 
Hi Claire,

Here is a better example - with the procedure header -

Private Sub Combo2_BeforeUpdate(Cancel As Integer)
If MsgBox("Do you want to update?", vbQuestion + vbYesNo) = vbNo Then
Cancel = True
Me.Combo2.Undo
End If

End Sub

You will notice that Cancel is declared as a parameter of the event
procedure so you do not have to declare it.

What is not working for you? If your combo is not bound then the undo will
not work. Instead just set the value of the control to Null or "".

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

Well I had that except for the cancel = true - and it
doesn't work in my form...?

what is Cancel? Do I have to make a special declare to
make it work?

Claire
-----Original Message-----
Create a BeforeUpdate Event for the combo:

If MsgBox("Do you want to update?", vbQuestion + vbYesNo) = vbNo Then
Cancel = True
Me.fSubject.Undo
End If


--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

I have a combo box linked to a control source.

When I pick a new value from the drop down list, the
record is updated.

I would like to be able to "regret" the change - i.e.
before update be asked "do you want to update? - yes / no"

On no I would like to undo the change.

How is that done?
.
 
Back
Top