How to combine 2 linked Excel tables in access 2003 with same field names, using query?
5 pts.
0
Q:
How to combine 2 linked Excel tables in access 2003 with same field names, using query?
I have 3 employees working who have no access on their PC. they are performing their data entry in excel and I ahve linked all three tables to one access file as I have Access on my PC. I need to combine all 3 tables using query or some other method in access to create one master table. Here is the example of data entered by each employee.

                   Field name1         Field name2       Field name3

                   Emploee ID         CustomerID         Address

table1          1222                   001                    123 main st

                   1222                   002                    123 king st

table2          1233                   003                    11 john st

                   1233                   006                    22 hughson st

table3          1244                   004                     11 mary st

                   1244                   005                      93 king st

 

Is there any way to combine these data using query to come up with one master table showing the following?

 

                   Emploee ID         CustomerID         Address

                   1222                   001                    123 main st

                   1222                   002                    123 king st

                   1233                   003                    11 john st

                   1233                   006                    22 hughson st

                   1244                   004                     11 mary st

                   1244                   005                      93 king st

 Any help on this would be greatly appericiated.

 

Thanks you in advance.



Software/Hardware used:
2003 microsoft office/ access
ASKED: Nov 5 2009  6:37 PM GMT
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
0
1410 pts.
0
A:
 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0
  • AddThis Social Bookmark Button
For the linked table approach. Make a Union query in Access.

Select EmployeeID, CustomerID, Address From LinkedTable1
Union All
Select EmployeeID, CustomerID, Address From LinkedTable2

This should do what you are asking for. The All part of the union brings in records that might be the same in both tables. If it could happen that the same records are in both tables and you don't want both of the records, take off the All clause.
Last Answered: Nov 6 2009  8:59 PM GMT by Randym   1410 pts.
0
0
Discuss This Answer:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

Craig Hatmaker   0 pts.  |   Nov 5 2009  7:51PM GMT

Here is a different approach.

Rather than merge the tables in Access, use XL as a multiuser data entry program to post to a single Access Table somewhere on the network.

This approach requires VBA macros in XL.

1) Create a button to for the user to click and post the data.

2) Assign a Macro to the button that reads the XL range and formats the entries into an SQL INSERT Statement (example:)

sSQL = “INSERT INTO myAccessTable EmployeID, CustomerID, Address VALUES (’” & cell(1, 1) & “‘, ‘” & cell(1,2) & ‘”, ” & cell(1,3) & “‘ ”

3) Call the routine below with the SQL string and a connection string pointing to your access data.

Public Function SQLExec(sSQL As String, sConnect As String) As Variant

‘ SQLExec: Execute and SQL Statement

‘Prerequisites:
‘ Include “Microsoft ActiveXData Objects 2.0 Library” or higher reference

‘ Parameters: sSQL - a string containing an SQL command to execute
‘ sConnect - a connection string
‘ Example: bResult = SQLExec(”CREATE INDEX index_name ON table_name (column_name)”, _
‘ “ODBC;DSN=AS400;Driver={iSeries Access ODBC Driver}”)

‘ Date Init Modification
‘ 01/01/01 CWH Initial Programming

On Error GoTo ErrHandler
SQLExec = “Failure” ‘Assume Something went wrong

Dim cn As ADODB.Connection
Dim errLoop As ADODB.Error

On Error GoTo ErrHandler
Debug.Print “Start:”, Time, sSQL
Set cn = New ADODB.Connection
cn.Properties(”Prompt”) = adPromptComplete
cn.Open sConnect, “”, “”
cn.Execute sSQL
Debug.Print “End:”, Time

‘ Application.StatusBar = cn.RecordsAffected & ” Records affected.”
If cn.Errors.Count = 0 Then
SQLExec = Success
Else
SQLExec = cn.Errors(0).Description
End If

ErrHandler:

On Error Resume Next
If Err.Number <> 0 Then
SQLExec = “Failure”
If Err.Number <> 0 Then
MsgBox “SQLExec - Error#” & Err.Number & vbCrLf & Err.Description, _
vbCritical, “Error”, Err.HelpFile, Err.HelpContext
Else
For Each errLoop In cn.Errors
MsgBox “Error number: ” & errLoop.Number & vbCr & _
errLoop.Description, vbCritical, “Error”, errLoop.HelpFile, errLoop.HelpContext
Next errLoop
End If
End If
cn.Close
On Error GoTo 0

End Function

 
0