One column into two. (1 Viewer)

AccessVBAUser

New member
Local time
Today, 11:36
Joined
Feb 13, 2009
Messages
3
Hello,
I have been given a list of names in excel. I have imported those names into a table in access named Employee. So the table, column and names look like:
Table: Employee
Column: Employee
Row1 Todd
Row2 Mike
Row3 Sarah
I need to take this table and turn it into a table (like a matrix in theory) that has each distinct combination of names and without having two of the same (ie Todd cant be in column1 and column2). For example:
Column1 Column2
Todd Mike
Todd Sarah
Sarah Mike

The code i had started is as followed:

Dim empArray(rst.RecordCount, rst.RecordCount) As String

'SET RECORDSET 1
strSql = "Select Employee from Employee"
Set rst = dbs.OpenRecordset(strSql)

'SET RECORDSET 2
strSql2 = "Select Employee from Employee"
Set rst2 = dbs.OpenRecordset(strSql2)

rst.MoveFirst
rst2.MoveFirst

Do Until rst2.EOF
Do Until rst.EOF
empArray = (rst2.GetRows(1, y) , (rst1.GetRows(1, x))

rst.MoveNext
Set x = x + 1
Loop
rst.MoveFirst
rst2.MoveNext
Set y = y + 1
Loop

Any help would be greatly appreciated. I have been tasked with getting this done ASAP and am not very experienced working in this realm. Thank you so much.
 
Last edited by a moderator:

Brianwarnock

Retired
Local time
Today, 19:36
Joined
Jun 2, 2003
Messages
12,701
Will a query do?

See attached.

Brian
 

Attachments

  • forumnames.mdb
    176 KB · Views: 167

Brianwarnock

Retired
Local time
Today, 19:36
Joined
Jun 2, 2003
Messages
12,701
BTW The query is easier to understand in SQL view rather than the Design Grid.

Brian
 

AccessVBAUser

New member
Local time
Today, 11:36
Joined
Feb 13, 2009
Messages
3
Yes, that is exactly what i was looking for. I don't know why i didn't think of that. Thank you so much for your help and timely response.
 

Brianwarnock

Retired
Local time
Today, 19:36
Joined
Jun 2, 2003
Messages
12,701
Probably by now you have tidied up the query to

Code:
SELECT employees.Employee, employees_1.Employee
FROM employees, employees AS employees_1
WHERE employees.id< employees_1.id
ORDER BY employees.id;
the
employees.Employee<>employees_1.Employee
was part of the thinking process but is made redundent by the rest of the Where condition.

Brian
 

Users who are viewing this thread

Top Bottom