Solved

OldValue and case-sensitivity

Posted on 2012-04-11
4
264 Views
Last Modified: 2012-04-11
I need to prevent editing of a field after the record has been saved.  The analyst wishes to accomplish this by doing a check when the record is saved, and then display a message.

So, I did this:

 
   If Not frmMe.NewRecord Then
    If (TStr(frmMe!txtTestId.OldValue) <> TStr(frmMe!txtTestId)) Then
        Msg_Err GetStringConst("Test", 280)
        Cancel = True
        GoTo ExitRoutine
    End If
   End If

Open in new window


The problem is, this check does not recognize that the value is different if you simply change the case of the value.

In other words, if txtTestId.OldValue is "DEF", and I change the value of txtTestId to "def", the two values are interpreted as equal, so the message does not display.

How do I make this check case-sensitive?

Thanks!
0
Comment
Question by:L_Malchiodi
4 Comments
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
ID: 37832962
Checkout the strComp() function in Access Help
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 37832984
here is one quick way
in the top of your Form module, use

Option Compare Binary
0
 
LVL 26

Expert Comment

by:Nick67
ID: 37833015
Go sideways!
Lock that control if you are not on a new record

If Not frmMe.NewRecord Then
    frmMe!txtTestId.locked = true
else
    frmMe!txtTestId.locked = false
end if

Then nobody can change it if you aren't on a new record
0
 

Author Closing Comment

by:L_Malchiodi
ID: 37833042
Thanks, StrComp worked nicely.  I changed the line where the check is done to this:

If StrComp(TStr(frmMe!txtTestId), TStr(frmMe!txtTestId.OldValue), 0) <> 0 Then
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
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…

713 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