Link to home
Start Free TrialLog in
Avatar of cansevin
cansevin

asked on

Look up value before

I am going to be using the below code for a very un-secure password that must be entered in order for an invoice price to be changed. The code is the invoice number minus 1,111 and then times two.

I believe I have to build a seperate query where the proper pass code will be stored, is that correct? If so, how to I write that sperate query? I believe that is the "vbOKOnly" section. I'm not sure where to properly tell it to look for the correct passcode. Thanks!


BeforeUpdate event of the Price control
If Me.SomeDate <  Date() - 1 Then
    If InputBox("Enter Password" <> "some string") Then
        Cancel = True
        Msgbox "Change not allowed without valid password.",vbOKOnly
        Me.Price.Undo
        Exit Sub
    End If
End If
Avatar of TheNautican
TheNautican

This code appears to be a sample in which you need to modify for your own uses. Lets say that that invoice is held in a field called MyInvoice the code might look something like this. Thanks to a snowday!!! I can't get on my window machine to test this out, but try it and let us know.

Dim strCorrectPassword as String

strCorrectPassword = (me.MyInvoice - 1111) * 2

If Me.SomeDate <  Date() - 1 Then 'Reads in a date field on your from called "Some Date"
    If InputBox("Enter Password" <> strCorrectPassword) Then 'Compares passwords
        Cancel = True
        Msgbox "Change not allowed without valid password.",vbOKOnly
        Me.Price.Undo 'undo recent change to this field
        Exit Sub
    End If
End If 

Open in new window



Regards,
-Naut
SOLUTION
Avatar of Hamed Nasr
Hamed Nasr
Flag of Oman image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cansevin

ASKER

Thanks guys... works great! I have follow up question I need help with, I'll post that separately.