Returning a field to its previous value

  • Thread starter Thread starter Dave Moss
  • Start date Start date
D

Dave Moss

Hello,

I am writing a procedure for the 'Before Update' event of
a combo box control.

The code checks to see whether the record selected from
the combo list has already been used elsewhere on the form.

If it has, then a message box is shown:
RetValue = MsgBox("Continue?", vbOKCancel)

If the user chooses 'cancel', how do I use the returned
value (2) to return the control to its original position?
i.e. showing the previous field value?
 
Hello,

I am writing a procedure for the 'Before Update' event of
a combo box control.

The code checks to see whether the record selected from
the combo list has already been used elsewhere on the form.

If it has, then a message box is shown:
RetValue = MsgBox("Continue?", vbOKCancel)

If the user chooses 'cancel', how do I use the returned
value (2) to return the control to its original position?
i.e. showing the previous field value?
How about?

If MsgBox("Continue?", vbOKCancel) = vbCancel Then
Cancel = True
End If

- Jim
 
Hi,
If the user wishes to cancel, just set Cancel = True
in the procedure.

If MsgBox("Continue?", vbOKCancel) = vbCancel Then
Cancel = True
Else
'do whatever
End If
 
Dave said:
I am writing a procedure for the 'Before Update' event of
a combo box control.

The code checks to see whether the record selected from
the combo list has already been used elsewhere on the form.

If it has, then a message box is shown:
RetValue = MsgBox("Continue?", vbOKCancel)

If the user chooses 'cancel', how do I use the returned
value (2) to return the control to its original position?
i.e. showing the previous field value?


If RetValue = vbCancel Then
Me.combobox.Undo
Cancel = True
End If
 
In addition to the other suggestions, if the combo box is bound to a field,
you can insert the code steip
Me.ComboBoxName.Undo

in the code right after the Cancel = True line.
 
Thanks
-----Original Message-----
In addition to the other suggestions, if the combo box is bound to a field,
you can insert the code steip
Me.ComboBoxName.Undo

in the code right after the Cancel = True line.

--

Ken Snell
<MS ACCESS MVP>




.
 
Back
Top