N
Niklas Östergren
Hi!
I have a form in which I´d like to ask the user if he/she rely want´s to
change a value in a record. And if the user answer NO I´d like to set the
old stored value back in the textfield else continue.
So I have the folowing code in the forms textbox:
===============================================
Private Sub txtParameterNo_BeforeUpdate(Cancel As Integer)
If MsgBox("Vill du verkligen ändra parameternumret?" & Chr(13) & Chr(10) &
"Det är väldigt ovanligt!", vbYesNo, "Ändra parameternummer") = vbNo Then
Me.txtParameterNo = lngPublicOldParameterNo
Cancel = True
End If
End Sub
Private Sub txtParameterNo_Dirty(Cancel As Integer)
lngPublicOldParameterNo = Me.txtParameterNo
End Sub
=================================================
lngPublicOldParameterNo is declared in the top of the code module:
Public lngPublicOldParameterNo As Long ' Holds old parameter number (before
change)
Now to my problem:
If the user answer NO on the msgbox after changing the value in
txtParameterNo then I get an runtime error:
Runtime error no. '-2147352567 (80020009)'
And the line "Me.txtParameterNo = lngPublicOldParameterNo" is higlighted.
When I hover above the variables the both contain the values exepcted. In
this case I have tryed to change Me.txtParameterNo from 2 to be 222 instead.
So at this moment Me.txtParameterNo have value 222 and
lngPublicOldParameterNo have value 2.
And since I answered NO on the mshbox I´d like Me.txtParameterNo to get
value 2 instead of 222.
Anyone have any clue of what I´m doing wrong here?
TIA
// Niklas
I have a form in which I´d like to ask the user if he/she rely want´s to
change a value in a record. And if the user answer NO I´d like to set the
old stored value back in the textfield else continue.
So I have the folowing code in the forms textbox:
===============================================
Private Sub txtParameterNo_BeforeUpdate(Cancel As Integer)
If MsgBox("Vill du verkligen ändra parameternumret?" & Chr(13) & Chr(10) &
"Det är väldigt ovanligt!", vbYesNo, "Ändra parameternummer") = vbNo Then
Me.txtParameterNo = lngPublicOldParameterNo
Cancel = True
End If
End Sub
Private Sub txtParameterNo_Dirty(Cancel As Integer)
lngPublicOldParameterNo = Me.txtParameterNo
End Sub
=================================================
lngPublicOldParameterNo is declared in the top of the code module:
Public lngPublicOldParameterNo As Long ' Holds old parameter number (before
change)
Now to my problem:
If the user answer NO on the msgbox after changing the value in
txtParameterNo then I get an runtime error:
Runtime error no. '-2147352567 (80020009)'
And the line "Me.txtParameterNo = lngPublicOldParameterNo" is higlighted.
When I hover above the variables the both contain the values exepcted. In
this case I have tryed to change Me.txtParameterNo from 2 to be 222 instead.
So at this moment Me.txtParameterNo have value 222 and
lngPublicOldParameterNo have value 2.
And since I answered NO on the mshbox I´d like Me.txtParameterNo to get
value 2 instead of 222.
Anyone have any clue of what I´m doing wrong here?
TIA
// Niklas