append contents of field to another field

  • Thread starter Thread starter RipperT
  • Start date Start date
R

RipperT

Hello,

I would like to (using code) have text data from a table field be
automatically appended to the end of text data entered in another field.
Specifically,

Field 1: "123456"
Field 2: "ww.somewebaddress.net/subfolder/" (default value)

I need the result of field 2 to look like this:
"ww.somewebaddress.net/subfolder/123456"

without having to type the contents of field 1 twice. How would I do this?

Many thanx,

Rip
 
RipperT @comcast.net> said:
Hello,

I would like to (using code) have text data from a table field be
automatically appended to the end of text data entered in another
field. Specifically,

Field 1: "123456"
Field 2: "ww.somewebaddress.net/subfolder/" (default value)

I need the result of field 2 to look like this:
"ww.somewebaddress.net/subfolder/123456"

without having to type the contents of field 1 twice. How would I do
this?

Many thanx,

Rip

It's easy enough to do, but why do it? Are you planning to remove Field
1 from your table? If both Field 1 and Field 2 are going to exist in
your table, then why not just use a calculated field in query to
concatenate them whenever necessary? Like this:

SELECT [Field2] & [Field 1] AS WebPage FROM MyTable;
 
It's easy enough to do, but why do it?

I have field two in a form with a button next to it whose On_click event
contains this:

Application.FollowHyperlink Me.Field2, , True

If I create a query with the concatenation, how will I adjust the above
line of code to open the link? And, I'm thinking it will be slower in
opening, too, but maybe not. What do you think?

Thanx,
Rip


Ripper T Smith
rippertsmith<nospam>@comcast.net
Dirk Goldgar said:
RipperT @comcast.net> said:
Hello,

I would like to (using code) have text data from a table field be
automatically appended to the end of text data entered in another
field. Specifically,

Field 1: "123456"
Field 2: "ww.somewebaddress.net/subfolder/" (default value)

I need the result of field 2 to look like this:
"ww.somewebaddress.net/subfolder/123456"

without having to type the contents of field 1 twice. How would I do
this?

Many thanx,

Rip

It's easy enough to do, but why do it? Are you planning to remove Field
1 from your table? If both Field 1 and Field 2 are going to exist in
your table, then why not just use a calculated field in query to
concatenate them whenever necessary? Like this:

SELECT [Field2] & [Field 1] AS WebPage FROM MyTable;

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
RipperT @comcast.net> said:
I have field two in a form with a button next to it whose On_click event
contains this:

Application.FollowHyperlink Me.Field2, , True

If I create a query with the concatenation, how will I adjust the above line
of code to open the link?

You won't. It will still work just as if it were in a field in the table.

And, I'm thinking it will be slower in
opening, too, but maybe not. What do you think?

Nope. The code can't tell the difference. All it sees is the result of the
expression.
 
Thanx, Rick,

I was thinking saved query, for some reason. So (just to be sure), the
control source of field 2 will contain the query, yes?
Thanx a bazillion,

Rip
 
RipperT @comcast.net> said:
Thanx, Rick,

I was thinking saved query, for some reason. So (just to be sure), the control
source of field 2 will contain the query, yes?
Thanx a bazillion,

No, a TextBox ControlSource cannot be a query, only a field or expression. You
would bind your form to a query instead of a table and that query would contain
the concatenated field. Then you bind the TextBox to that field.
 
I don't understand. I cannot bind the form to a query instead of the table.
It is the main form used to manipulate the table data. I spent a good deal
of time making this form functional; I cannot change it now. Am I
misunderstanding this?

Thanx for your patience.

Rip
 
RipperT @comcast.net> said:
I don't understand. I cannot bind the form to a query instead of the table. It
is the main form used to manipulate the table data. I spent a good deal of time
making this form functional; I cannot change it now. Am I misunderstanding
this?

It would be a query that included all the fields from your table PLUS the
calculated field with the concatenated result. Your form will never know the
difference.

(most people bind to queries, not tables)
 
RipperT @comcast.net> said:
I have field two in a form with a button next to it whose On_click
event contains this:

Application.FollowHyperlink Me.Field2, , True

If I create a query with the concatenation, how will I adjust the
above line of code to open the link? And, I'm thinking it will be
slower in opening, too, but maybe not. What do you think?

I agree with everything Rick Brandt has posted in this thread. As an
alternative, if both Field1 and Field2 are present in your form's
recordsource, you could -- without changing anything else -- change the
line of code you posted above to this:

Application.FollowHyperlink Me.Field2 & Me.Field1, , True
 
Back
Top