Solved

Look up value before

Posted on 2014-02-05
4
240 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 34

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

706 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now