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?
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 ... - SELECT tblSaleperson.*, tblLeads.*, tblSales.*
-
FROM tblSalesperson LEFT JOIN tblLeads
-
ON tblSalesperson.SalespersonID=tblLeads.SalespersonID
-
(LEFT JOIN tblSales
-
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
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?
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.
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.
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. - Private Sub cmdButton1_Click()
-
Dim rs As DAO.Recordset
-
Dim qdf As DAO.QueryDef
-
Dim strSQL As String
-
Dim path As String
-
-
' find the path for the current division
-
path = "C:\FolderName\" ' Path to the folder you want to export to
-
-
With CurrentDb
-
Set rs = .OpenRecordset("tblSalesperson") ' replace with name of your salespeople table
-
-
rs.MoveFirst
-
'For each person in the table
-
Do Until rs!EOF
-
' Set up SQL query string, replace with your field names, query name, salesperson unique id etc.
-
strSQL = "SELECT Field1, Field2 FROM MyQueryName WHERE SalespersonID=" & rs!SalespersonID
-
' createquerydef command line follows
-
Set qdfNew = .CreateQueryDef("My_Query", sqltext)
-
DoEvents
-
' save the query to Excel, replace surname and firstname with your appropriate field names
-
DoCmd.OutputTo acOutputQuery, "My_Query", acFormatXLS, path & rs!FirstName & "_" & rs!Surname & Format(Now, "ddmmyyyy hhmm") & ".xls", True
-
' delete the temporary query
-
DoCmd.DeleteObject acQuery, "My_Query"
-
qdfNew.Close
-
Set qdfNew = Nothing
-
rs.MoveNext
-
Loop
-
-
rs.Close
-
Set rs = Nothing
-
End With
-
-
End Sub
Thanks for all your help. I'll give it a go this week.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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...
|
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...
|
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...
|
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...
| |
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,...
|
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...
|
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...
|
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...
|
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...
|
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,...
| |
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...
|
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,...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |