Copy one field in two or more fields

  • Thread starter Diego via AccessMonster.com
  • Start date
D

Diego via AccessMonster.com

Hi
i have a tableA with one field and another tableB with two fields.

TableA
Name
a
b
c
d
e
f
..
...

I want copy all values alternatively, in an another tableB with two fields.
The results should be:
TableB
NameA NameB
a b
c d
e e
..

Anyone can be help me ?
Thank you in advance
Best regards
Diego
 
M

Marshall Barton

Diego said:
i have a tableA with one field and another tableB with two fields.

TableA
Name
a
b
c
d
e
f
..

I want copy all values alternatively, in an another tableB with two fields.
The results should be:
TableB
NameA NameB
a b
c d
e e
.

Anyone can be help me ?


No can do unless you can explain the *very* precise rules
that determine which record in table A goes to which record
and field in table B. Since the records in a table can be
presented in any order, you *must* have some information in
table A that can be used to determine that name a and name b
go together and which one comes first. The standard way is
to have sufficient data in other fields than can be used to
specify a unique sort that presents the records in the order
in your example.
 
D

Diego via AccessMonster.com

In this case the rule is that even adn odd records are copied in a table
and/or other.

ID Name
1 a
2 b
3 c
4 d
...

copied into two fields

Even odd
a b
c d

Regards


Marshall said:
i have a tableA with one field and another tableB with two fields.
[quoted text clipped - 18 lines]
Anyone can be help me ?

No can do unless you can explain the *very* precise rules
that determine which record in table A goes to which record
and field in table B. Since the records in a table can be
presented in any order, you *must* have some information in
table A that can be used to determine that name a and name b
go together and which one comes first. The standard way is
to have sufficient data in other fields than can be used to
specify a unique sort that presents the records in the order
in your example.
 
M

Mike Painter

Diego said:
Hi
i have a tableA with one field and another tableB with two fields.

TableA
Name
a
b
c
d
e
f
.
..

I want copy all values alternatively, in an another tableB with two
fields. The results should be:
TableB
NameA NameB
a b
c d
e e
.
What Marshall said is true.
If it is always a first name, last name situition, this might be OK.
If all the values are the same kind of name then it would be a bad idea.
 
M

Marshall Barton

You must be able to **absolutely guarantee** that every
record's ID field strictly adheres to that rule. (Note: an
AutoNumber field can not provide that guarantee.)

If so, you can use a query that joins the table to itself to
get the correct two names together in the same record.

SELECT TableA.[Name] As FN, TableA1.[Name] As LN
FROM TableA INNER JOIN TableA As TableA1
ON TableA.ID = TableA1.ID + 1

Note: This kind of query must be done in SQL view because
the query designer is not able to deal with non-equal joins.

That query can be used as the basis for a MakeTable or
Append query to populate tableB.
 
D

Diego via AccessMonster.com

Hi
the result is a little different. Starting from a Table A
ID Name
1 a
2 b
3 c
4 d
5 e
6 f

the query gives this result

FN LN
b a
c b
d c
e d
f e

It should be
FN LN
a b
c d
e f

sorry but i am confusing
Let me know
Diego


Marshall said:
You must be able to **absolutely guarantee** that every
record's ID field strictly adheres to that rule. (Note: an
AutoNumber field can not provide that guarantee.)

If so, you can use a query that joins the table to itself to
get the correct two names together in the same record.

SELECT TableA.[Name] As FN, TableA1.[Name] As LN
FROM TableA INNER JOIN TableA As TableA1
ON TableA.ID = TableA1.ID + 1

Note: This kind of query must be done in SQL view because
the query designer is not able to deal with non-equal joins.

That query can be used as the basis for a MakeTable or
Append query to populate tableB.
In this case the rule is that even adn odd records are copied in a table
and/or other.
[quoted text clipped - 25 lines]
 
M

Marshall Barton

Diego said:
the result is a little different. Starting from a Table A
ID Name
1 a
2 b
3 c
4 d
5 e
6 f

the query gives this result

FN LN
b a
c b
d c
e d
f e

It should be
FN LN
a b
c d
e f

I knew dat :-|

Sorry, let's try this:

SELECT TableA.[Name] As FN, TableA1.[Name] As LN
FROM TableA INNER JOIN TableA As TableA1
ON TableA.ID = TableA1.ID - 1
WHERE (TableA.ID Mod 2) = 1
 
D

Diego via AccessMonster.com

Great !
It is works.
Thank you very much
Diego

Marshall said:
the result is a little different. Starting from a Table A
ID Name
[quoted text clipped - 19 lines]

I knew dat :-|

Sorry, let's try this:

SELECT TableA.[Name] As FN, TableA1.[Name] As LN
FROM TableA INNER JOIN TableA As TableA1
ON TableA.ID = TableA1.ID - 1
WHERE (TableA.ID Mod 2) = 1
 

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