Access 2k field change verification

usmc-ratman

Registered User.
Local time
Today, 04:14
Joined
May 27, 2005
Messages
20
On a form, need assistance in fixing a vb script msgbox problem. I have placed the code listed below to verify that the user wants to change an existing value in a field. The code below works fine, UNLESS the user has made other changes on the form prior to changing the checked fields
There are 2 fields ("NoBill" and "Lname") that are checked for changes. But if someone changes a remarks or other field in the form prior to changing "NoBill", and when the msgbox pops up to verify the change, if the user selects "NO", then the other fields that were changed before are also undone.
Q: how to just undo that particular field, not all the changed entries on the form.

Code:
Public Function Conf()
Dim Msg, Style, Title, Response, MyString

Beep
Msg = "You have altered existing data are you sure you wish to do this?"
Style = vbYesNo + vbExclamation + vbDefaultButton1
Title = "Confirm record change"
Response = MsgBox(Msg, Style, Title)
If Response = vbNo Then
Screen.ActiveForm.Undo
Exit Function
DoCmd.RunCommand acCmdSaveRecord

End If
End Function

and then in the Before Update properties

Code:
Private Sub NoBill_BeforeUpdate(Cancel As Integer)
    If Not Me.NewRecord And Me.Dirty Then
        Call Conf
    End If
End Sub

I tried creating two separate public functions ("Conf_NoBill" and "Conf_Lname"), and calling those particular functions based on those fields' Before Update properties, but it still didnt work. HeEeelLlLp ?!??:confused:

Thank you in advance,
Semper Fi
JR

Prog: Access 2000
OS: WinXP Pro SP3
 
i think, only by asking the question in the beforeupdate event of each field, not for the form as a whole

"undoing" the form does exactly that - resets the whole record

out of interest, i think the save record command can never get called in your sub - is that what you meant, or is this a coding error

If Response = vbNo Then
Screen.ActiveForm.Undo
Exit Function
DoCmd.RunCommand acCmdSaveRecord

End If
 
husky,
I think your probably right, the 'DoCmd.RunCommand acCmdSaveRecord' line may not be needed, as the record will be saved when they move out of that record.
I'm just having a problem limiting the 'undo' function to just that field that is protected.
I only have the two fields that need to require a response to a change in the field. The other dozen fields on the form change frequently. I just need to limit the scope of the undo.
Hope this is making sense. I'm sure this should be simple, and I was told one possibility would be to set a Global Public Variable and when the user Sets the Focus on the field requiring verification, pass the current value to the Variable. Then use the Field's After Update event to compare before and after values and if different ask if the user is sure they want to change the value. If they say No then put back the value from the variable back in the field.

I just dont know how to code the passing of the variables and get that to work. Be researching it all morning, eyes going crossed.
Any suggestions or sample code?

Thanks,
JR
 
hey guys - sorry forgot to close this thread out as solved / closed....
 

Users who are viewing this thread

Back
Top Bottom