Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Look up value before

Posted on 2014-02-05
4
Medium Priority
?
259 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 39

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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

670 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