473,480 Members | 1,982 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Can I create a make table query that will make multiple tables ?

I want to create a different table for each sales person listed in a table. If I have salesperson1 through salespersonN listed in the table, I'd like to end up with a table for salesperson1 with just salesperson1 data through salespersonN with just salespersonN's data.

The resultant tables would be named something like

salesperson1 table1
through
salespersonN table1

Make sense?
Sep 27 '10 #1
6 6718
MMcCarthy
14,534 Recognized Expert Moderator MVP
Your question makes sense, it's just not the way that databases work.

So lets say you have a table for salespeople, then a table for leads and a table for sales.

You then would have something like this

tblSalespeople
SalespersonID (Primary key)
FirstName
Surname
Etc

tblLeads
LeadID (Primary key)
SalespersonID (Foreign key to tblSalesperson)
LeadName
PhoneNum
Etc

tblSales
SalesID
SalespersonID
CustomerName
Etc

Then using a query something like ...

Expand|Select|Wrap|Line Numbers
  1. SELECT tblSaleperson.*, tblLeads.*, tblSales.*
  2. FROM tblSalesperson LEFT JOIN tblLeads
  3. ON tblSalesperson.SalespersonID=tblLeads.SalespersonID
  4. (LEFT JOIN tblSales
  5. ON tblSalesperson.SalespersonID=tblSales.SalespersonID
You can retrieve the information you need for each sales person. For further information check out this insight.
Database Normalization and Table Structures
Sep 27 '10 #2
I really owe you a little more explanation. From time to time I send a personalized excel file to each salesperson asking them review and mark up a listing of a subset of their accounts with various information I generally collect yes/no type of data for a specific question about the account.
If my sales people could use Access I'd build a form where they choose their accounds to collect their data right into a table.
Unfortunately, I have to expernalize data and then import.
Does that help explain why I'm doing this silly thing?
Sep 27 '10 #3
MMcCarthy
14,534 Recognized Expert Moderator MVP
That helps explain it a little better :)

Still don't think its a good idea to create a lot of tables though. So if I understand correctly, you are going to import/link each excel sheet and then try to create a table from the data and then use the subsequent tables to update your data.

If that is what you are trying to do it would be easier to use vba code to automate the process. However, I don't know how familar you are with vba code.
Sep 27 '10 #4
Not familiar with VBA but can learn.

Best scenario is I would write a macro to create a temp table, one salesperson at a time, and export to an excel file of that salesperson. So, in the end I'd have salesperson1.xls --> salespersonN in some directory somewhere.
Sep 27 '10 #5
MMcCarthy
14,534 Recognized Expert Moderator MVP
OK it sounds like you need to create dynamic queries.

You can put this code behind a command button.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdButton1_Click()
  2. Dim rs As DAO.Recordset
  3. Dim qdf As DAO.QueryDef
  4. Dim strSQL As String
  5. Dim path As String
  6.  
  7.     ' find the path for the current division
  8.     path = "C:\FolderName\" ' Path to the folder you want to export to
  9.  
  10.     With CurrentDb
  11.         Set rs = .OpenRecordset("tblSalesperson") ' replace with name of your salespeople table
  12.  
  13.         rs.MoveFirst
  14.         'For each person in the table
  15.         Do Until rs!EOF
  16.             ' Set up SQL query string, replace with your field names, query name, salesperson unique id etc.
  17.             strSQL = "SELECT Field1, Field2 FROM MyQueryName WHERE SalespersonID=" & rs!SalespersonID
  18.             '  createquerydef command line follows
  19.             Set qdfNew = .CreateQueryDef("My_Query", sqltext)
  20.             DoEvents
  21.             ' save the query to Excel, replace surname and firstname with your appropriate field names
  22.             DoCmd.OutputTo acOutputQuery, "My_Query", acFormatXLS, path & rs!FirstName & "_" & rs!Surname & Format(Now, "ddmmyyyy hhmm") & ".xls", True
  23.             ' delete the temporary query
  24.             DoCmd.DeleteObject acQuery, "My_Query"
  25.             qdfNew.Close
  26.             Set qdfNew = Nothing
  27.             rs.MoveNext
  28.         Loop
  29.  
  30.         rs.Close
  31.         Set rs = Nothing
  32.     End With
  33.  
  34. End Sub
Sep 27 '10 #6
Thanks for all your help. I'll give it a go this week.
Sep 27 '10 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

7
10172
by: Jay | last post by:
Hi everyone ! I hope someone will be able to help me with this problem. I currently have several tables in MySQL database. Below is my table structures. (Data type for each fields are...
0
1831
by: Gianfranco | last post by:
Hi I got a problem with 2 tables. I have a table, say A, with x records, coming from a make table query and a table, say B, with y records, coming from another make table query. I need to join...
1
436
by: JJ | last post by:
I have a Make Table query which uses a date parameter. Each time the user runs the query they will be prompted for a date. The table which is created should be named based on the date which they...
2
397
by: Mo Ka | last post by:
Hi all, Is there a function (or other method) to automatically append the system date to the output tablename of a make table query such that the new one does not overwrite an older table?. I...
7
3767
by: Nicolae Fieraru | last post by:
I have two tables, they contain: Table1: ID1, Name1, Address1, Purchase1 Table2: ID2, Name2, Address2, Purchase2 I need a query which creates Table3 with content from Table1 and Table2. The...
2
8594
by: Kathy Krizl | last post by:
I'm probably doing something stupid, but I have a make table query. One of the tables I reference has some check box fields in it. Their Data Type is Yes/No, their field property format is Yes/No,...
2
2082
by: Doc | last post by:
Per earlier post, I am trying to save 'out' production data from a program called Solomon - basically (I think) this was /is an Access/Sql based program. We are updating to different application...
3
3457
by: Robertf987 | last post by:
Hi, I'm a bit stuck with an access database. I'm using access 2000 if that's any help. Right, it's 3:40am right now and I'm rather tired, but I *hope* this makes sense. I have a table which...
1
1608
by: TC | last post by:
I'm experiencing an unusual problem. When I run a specific make-table query on a computer, that computer shuts down. The computer shuts down completely, without warning, as if a power failure...
9
18722
by: Mourad | last post by:
Hi All, Is it possible to create a Make Table query in access (2.0 and 2003) that creates the table into a SQL Server database? Following the steps: 1- Create New Query 2- Set Query Type as...
0
7054
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7102
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5357
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4798
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4495
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3000
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1310
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
570
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
199
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.