Programically Merging Data and Input Mask

G

Guest

Two controls on my form (PartNo) and (ExtNo) that I want to concatenate with
a web address prefix into a field called (InterAdd). The way i have it set up
now is ridiculous as the user enters a PartNo (e.g. 1234) and ExtNo (A4).
They then have to go to the third field (InterAdd) that has a fefault vaue of
http://www.mydb.com/ and manually re-enter the PartNo and ExtNo into the
InterAdd field so that it looks like this http://www.mydb.com/1234A4.

I tried adding the web extension to the input mask for InterAdd in Table
design but it was too long. I tried coding it on the form but 2 problems.
One, the user is still having to re-enter data. Two, the input mask part
"http://www.mydb.com/ is not populating into the field. How can I can I merge
PartNo and ExtNo into a single field InterAdd in which InterAdd has a
constant value? Thanks group.
 
A

Albert D. Kallal

You don't have to save, nor even write code here.

since you can create a expression, then during export, or even for reports,
you simply use that expression.

Place a un-bound text box on your form.

For the data source of this text box, go:

=("http:/www.mydb.com/" & [PartNum] & [ExtNo)

Now, when the user enters the two values, you will see how this text box
will ALWAYS be correct.

it also means that you don't have to go back and update or fixed the obvious
mistakes that users would make...

There is no need at all to store this value, or even as you ask...have users
enter the value....
 
A

Albert D. Kallal

MBoozer said:
Thanks Albert but I am not quite their yet. What I need is for this to
populate another Field called InterAdd

My point was since you already have other fields that makes up this results,
you DO NOT need to EVER store it...

It is no more, or less work to simply use a expression then it is to write
code to update that field.

Further, if you later use a update query, write some code that modifies the
data, then how will you ALWAYS ensure that this field that is a result of
SEVERAL OTHER fields always be correct?

Further to all of the above...how to you expect to update the existing data?

So, what I was saying, just use an expression, and you DO NOT have to worry
about ANY of the above problems...do you?

Worse, if you edit ExtNo, or partNum, then you have to write code that
ensures that you update the interadd field.

? so the expression would look something
like

[InterAdd]=("http:/www.mydb.com/" & [PartNum] & [ExtNo)
but I keep getting a Name? error.


However, you can not do an assignment in an text box expression. You have
ONLY two choices for a text box:

You set the underlying field
or
You use an expression - expression are NOT stored....you cannot store
expressions.

If you really really really must store this data (i.e.: for some reason you
go against all of the above advice, and really want to spend your time on
something that you don't need to do, then you will have to use the after
update event of the [partnum] event. You will also have to put the code in
the after update event of the ExtNo also. (since a user might edit either
one...you have to take this into account). You could also use the before
update event of the record..but, then you only see the expression when you
return to that record on the form....


The code to actually store the value would be placed in the after update
event of the two text boxes..and would look like:


me!InterAdd= "http:/www.mydb.com/" & [PartNum] & [ExtNo]

The above code would be placed in the after update event of both the partnum
text box, and the ExtNo text box.....

As mentioned, you can/should use an expression on a UN-BOUND text box, and
you don't need any code...nor any need to store the value, since an
expression can create the value you need any time....

That expression (as mentioned) for the text box would be:


=("http:/www.mydb.com/" & [PartNum] & [ExtNo])

(note that missed a square bracket in the original post) (note also, how
this expression is just that ...an expression..and you can see that it is
not stored anywhere..nor is any destination for the text box specified (or
even can be specified).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top