Re: How to capture inserted value
- From: "Larry Linson" <bouncer@xxxxxxxxxxxxx>
- Date: Thu, 28 Jun 2007 19:26:33 GMT
What you are doing sounds much like "multivalue fields", which are a
violation of relational design (but, despite which, Microsoft chose to
include in Access 2007 but tried to avoid controversy by calling it "complex
data"). If you'd explain what data you have and what you're trying to
accomplish, there's a good chance that someone would be able to suggest a
better solution than "multivalue fields" if that's really what it is.
I'm not sure what jahoobob provided... it seemed to consolidate the values
of two Controls, when I understood you wanted to split them.
Value provides the _current_ content of the Control.
If your "inserted value" will always begin with a carriage return, then you
can use the InStrRev (in recent versions of Access, or equivalent code in
earlier versions) to locate the carriage return, calculate the length, and
obtain the newly-added part by using the Right function.
However, unless you include VBA code to edit and validate, there's nothing
to keep a user from purposely or accidentally overtyping what's already
there, and the OldValue returns the value that was in the bound Field of the
RecordSource, when the Record was displayed. Or from adding a second
"insert", or ???
You could extract appended data by using the length of OldValue and Value,
for example:
Me.anotherCtl = Right(Me.origCtl, Len(Me.origCtl.Value) -
Len(Me.origCtl.OldValue))
but, let's just guess what would happen if the "insert" were actually
inserted... that is "def" were inserted between "a" and "b" of "abc" so that
OldValue = "abc" and Value = "adefbc".
Larry Linson
Microsoft Access MVP
"Kev" <Kevorn@xxxxxxxxx> wrote in message
news:1183013084.148576.179410@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hello world,
I am trying to capture the latest entry into a text box by the user
and then insert it in a separate text box. I must not be searching the
right key words because I can only find oldvalue and value (which is
the old value plus the inserted or changed value) It is the inserted
or changed value that I want.
I have tried
Dim strControlName As String, strContValue As String, strContOldValue
As String
strContValue = CrntCtl.Value
strContOldValue = CrntCtl.OldValue
Me!Changes = (strContValue - strContOldValue)
but got data type mismatch.
So in summary; I am trying to achieve:
Textbox1 contains
"abc"
User adds
Carraige Return "def"
Textbox1 now contains
"abc
def"
How do I capture "def"
Any help gratefully appreciated
Regards
Kevin
.
- References:
- How to capture inserted value
- From: Kev
- How to capture inserted value
- Prev by Date: Re: Access Forms with Calendar
- Next by Date: Re: Acc2007 - getPressed, should be so simple!
- Previous by thread: Re: How to capture inserted value
- Next by thread: update query
- Index(es):
Relevant Pages
|