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
Solved

OldValue and case-sensitivity

Posted on 2012-04-11
4
263 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

789 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