Solved

Look up value before

Posted on 2014-02-05
4
251 Views
Last Modified: 2014-02-05
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
0
Comment
Question by:cansevin
4 Comments
 
LVL 8

Expert Comment

by:TheNautican
ID: 39835976
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
0
 
LVL 30

Assisted Solution

by:hnasr
hnasr earned 250 total points
ID: 39836050
Agree with TheNautican's comment
Adding:
If invoce number is less than 1111 then result is negative, so use:
strCorrectPassword = Abs (me.MyInvoice - 1111) * 2
0
 
LVL 35

Accepted Solution

by:
PatHartman earned 250 total points
ID: 39836256
No points please -- Typo correction -

If InputBox("Enter Password") <> strCorrectPassword Then 'Compares passwords

The closing parenthesis needs to be moved to the left of the relational operator.
0
 

Author Closing Comment

by:cansevin
ID: 39836504
Thanks guys... works great! I have follow up question I need help with, I'll post that separately.
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question