Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Look up value before

Posted on 2014-02-05
4
Medium Priority
?
264 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 31

Assisted Solution

by:hnasr
hnasr earned 1000 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 40

Accepted Solution

by:
PatHartman earned 1000 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

916 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