msg box before update also show 'old' value

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have the following code in a txtLocation before update event:

If vbNo = MsgBox("Do you want to change to """ & _
Me.txtLocation.Value & """ location?", _
vbQuestion + vbYesNo + vbDefaultButton1, _
"Change the Status?") Then Cancel = True

I want to also show the 'old' value before the user typed over it. So the
msg box shows "Do you want to change 'old value' to 'new value' location?"

I suspect I need to capture the 'old' value in a variable and then use it in
my IF statement. Any clues?

Cheers,

nB
 
Hi,

I have the following code in a txtLocation before update event:

If vbNo = MsgBox("Do you want to change to """ & _
Me.txtLocation.Value & """ location?", _
vbQuestion + vbYesNo + vbDefaultButton1, _
"Change the Status?") Then Cancel = True

I want to also show the 'old' value before the user typed over it. So the
msg box shows "Do you want to change 'old value' to 'new value' location?"

I suspect I need to capture the 'old' value in a variable and then use it in
my IF statement. Any clues?

Cheers,

nB

MsgBox "Change " & Me![ControlName].OldValue & " to: " &
Me![ControlName].Text
 
Thanks, that helps heaps however I still have a problem.

When I change a value in the text box the before update event shows msg box
asking if I want to change "old value" to "text value". This is fine however
if I say no the focus goes back to the text box and the "text value" is still
there so I then have to type the "old value" back in - and of course when it
looses focus it now asks me if I want to change the "old value" to the "old
value".

How can I make the value of the text box revert back to the "old value" if I
select "No" from the message box and prevent the msg box appearing when I
looses focus. Code in before update event below:


If Me.NewRecord Then Exit Sub

If vbNo = MsgBox("Change """ & _
Me![txtLoc].OldValue & """ to """ & _
Me![txtLoc].Text & """ ?", _
vbQuestion + vbYesNo + vbDefaultButton1, _
"Change location name?") Then Cancel = True

Cheers,

nB

fredg said:
Hi,

I have the following code in a txtLocation before update event:

If vbNo = MsgBox("Do you want to change to """ & _
Me.txtLocation.Value & """ location?", _
vbQuestion + vbYesNo + vbDefaultButton1, _
"Change the Status?") Then Cancel = True

I want to also show the 'old' value before the user typed over it. So the
msg box shows "Do you want to change 'old value' to 'new value' location?"

I suspect I need to capture the 'old' value in a variable and then use it in
my IF statement. Any clues?

Cheers,

nB

MsgBox "Change " & Me![ControlName].OldValue & " to: " &
Me![ControlName].Text
 
Thanks, that helps heaps however I still have a problem.

When I change a value in the text box the before update event shows msg box
asking if I want to change "old value" to "text value". This is fine however
if I say no the focus goes back to the text box and the "text value" is still
there so I then have to type the "old value" back in - and of course when it
looses focus it now asks me if I want to change the "old value" to the "old
value".

How can I make the value of the text box revert back to the "old value" if I
select "No" from the message box and prevent the msg box appearing when I
looses focus. Code in before update event below:

If Me.NewRecord Then Exit Sub

If vbNo = MsgBox("Change """ & _
Me![txtLoc].OldValue & """ to """ & _
Me![txtLoc].Text & """ ?", _
vbQuestion + vbYesNo + vbDefaultButton1, _
"Change location name?") Then Cancel = True

Cheers,

nB

fredg said:
Hi,

I have the following code in a txtLocation before update event:

If vbNo = MsgBox("Do you want to change to """ & _
Me.txtLocation.Value & """ location?", _
vbQuestion + vbYesNo + vbDefaultButton1, _
"Change the Status?") Then Cancel = True

I want to also show the 'old' value before the user typed over it. So the
msg box shows "Do you want to change 'old value' to 'new value' location?"

I suspect I need to capture the 'old' value in a variable and then use it in
my IF statement. Any clues?

Cheers,

nB

MsgBox "Change " & Me![ControlName].OldValue & " to: " &
Me![ControlName].Text

You'll need to use the Control's AfterUpdate event for this:

If MsgBox("Change " & Me![ControlName].OldValue & " to " &
Me.[ControlName], vbYesNo) = vbNo Then
Me.[ControlName] = Me.[ControlName].OldValue
End If
 
Back
Top