This is a very nice site and I'd like to say thank you to the mdoerators and site administrator for maintaining. This is my first post; I hope someone can assist.
I'm working on a database for my wife. I pull reports from a program that defines the headings: SSN, NAME, DOB, PR EPR, Last EPR, SUPER, etc..
The supervisor = SUPER and the SSN = their Social Security Number
When I pull the data, the Super comes out with a Social Security Number. I need to establish a relationship or query that identifies the SSN by their NAME.
I can only download the main data in a set manner, there are no adjustments to the linked table in my database.
Example: - NAME SSN DOB EPR LAST SUPER
-
John Doe 111-11-1111 11/2/77 1/1/07 222-22-2222
-
Jane Doe 222-22-2222 3/4/70 12/4/06 445-22-1111
-
Jack Doe 333-11-2442 6/1/81 11/3/05 222-22-2222
In this illustration, you can see that Jane supervises John and Jack. 1) How do I get her name to come up in a query and all the personnel she supervises? 2) In a report, when I have SUPER selected, how can I get it to show the NAme instead of the social security number?
Thanks for the help!
MooseMan
19 2156
Hi MooseMan
Hide the SUPER field on the report but don't remove it. Now add a New text box and set the control source to -
=DLookup("[NAME]","Table or Query Name","SSN=" & [SUPER])
-
Mary
Thank you Mary! I'll give it a try.
I tried as suggested but to no avail, I had no luck. Any other suggestions?
-
=DLookup("[NAME]","Table or Query Name","SSN='" & [SUPER] & "'")
-
Had to modify Mary's code a little. SSN is stored as a text field.
NeoPa 32,556
Expert Mod 16PB
The recommended approach would be to link the table to itself in the source query (that would be another instance of itself). A LEFT JOIN would be required unless you could state categorically that all records have a SUPER value.
What do you currently have as the source of your form?
NeoPa 32,556
Expert Mod 16PB
BTW the other Experts here who posted the DLookup() solutions are both sacked (even though one outranks me of course). She should know better (tsk-tsk).
NeoPa 32,556
Expert Mod 16PB - SELECT T1.NAME,T1.SSN,T1.DOB,T1.[EPR LAST],
-
T1.SUPER,T2.Name AS SUPERNAME
-
FROM YourTable AS T1 LEFT JOIN YourTable AS T2
-
ON T1.SUPER=T2.SSN
Is the sort of thing you need. I don't know your table name so I improvised but I'm sure you get the idea. Using DLookup is actually something you can get away with in most cases, it just gets slower very quickly as the number of records to process increases (They know I'm just kidding). Not recommended as good design though.
The recommended approach would be to link the table to itself in the source query (that would be another instance of itself). A LEFT JOIN would be required unless you could state categorically that all records have a SUPER value.
What do you currently have as the source of your form?
Main Data Query is the source
NeoPa 32,556
Expert Mod 16PB
Main Data Query is the source
And ... ?
This is a very nice site and I'd like to say thank you to the mdoerators and site administrator for maintaining. This is my first post; I hope someone can assist.
I'm working on a database for my wife. I pull reports from a program that defines the headings: SSN, NAME, DOB, PR EPR, Last EPR, SUPER, etc..
The supervisor = SUPER and the SSN = their Social Security Number
When I pull the data, the Super comes out with a Social Security Number. I need to establish a relationship or query that identifies the SSN by their NAME.
I can only download the main data in a set manner, there are no adjustments to the linked table in my database.
Example: - NAME SSN DOB EPR LAST SUPER
-
John Doe 111-11-1111 11/2/77 1/1/07 222-22-2222
-
Jane Doe 222-22-2222 3/4/70 12/4/06 445-22-1111
-
Jack Doe 333-11-2442 6/1/81 11/3/05 222-22-2222
In this illustration, you can see that Jane supervises John and Jack. 1) How do I get her name to come up in a query and all the personnel she supervises? 2) In a report, when I have SUPER selected, how can I get it to show the NAme instead of the social security number?
Thanks for the help!
MooseMan
The easiest solution would be a variation of an Auto Join. Create a Query, then enter your Table in it twice. If your Table is named Table1, then entering it into the Query Grid again would produce Table1_2. Create a Join between the SSN Field of Table1 to the Super Field of Table1_2 (Table1.[SSN] ==> Table1_2.[SUPER]. Add any other Fields as required. Make this the Record Source for your Report, then set Hide Duplicates to Yes on the Name Field if so desired.
Okay,
I tried as suggested and the code did not list the name in place of the SSN, instead it lists error#.
Here is how the DB is set up... Tables: DOWNLOAD (Link table) and MAIN DATA. DOWNLOAD is the excel spreadsheet that has all the main information in it. I loaded that into MAIN DATA table so I can add additional fields. I did this because I can only download the DOWNLOAD sheet. How can I set up a feature that appends information to the MAIN DATA sheet when I update the DOWNLOAD linked table?
I have one query set up right now, Main Data Query. It pulls from MAIN DATA.
In the MAIN DATA, SUPER field is formated in this way: Number, 000-00-0000, and NAME field as text, 255
I really appreciate your help on this.
NeoPa 32,556
Expert Mod 16PB
Main Data Query is the source
And ... ?
Sorry to sound short with you, but I need to know more precisely what the name is ([Main Data]; [Main Data Query]) and I need to know what more you would like me to help with.
NeoPa 32,556
Expert Mod 16PB
Okay,
I tried as suggested and the code did not list the name in place of the SSN, instead it lists error#.
Here is how the DB is set up... Tables: DOWNLOAD (Link table) and MAIN DATA. DOWNLOAD is the excel spreadsheet that has all the main information in it. I loaded that into MAIN DATA table so I can add additional fields. I did this because I can only download the DOWNLOAD sheet. How can I set up a feature that appends information to the MAIN DATA sheet when I update the DOWNLOAD linked table?
I have one query set up right now, Main Data Query. It pulls from MAIN DATA.
In the MAIN DATA, SUPER field is formated in this way: Number, 000-00-0000, and NAME field as text, 255
I really appreciate your help on this.
I missed this earlier as I had loaded the page a while back.
I try to fit these in at work when I get a short break so I may have a number open for a while just waiting.
I'll read through this now and try to come back to you on it shortly.
NeoPa 32,556
Expert Mod 16PB
How can I set up a feature that appends information to the MAIN DATA sheet when I update the DOWNLOAD linked table?
I don't understand this question :(
I have one query set up right now, Main Data Query. It pulls from MAIN DATA.
In the MAIN DATA, SUPER field is formated in this way: Number, 000-00-0000, and NAME field as text, 255
Is the data you showed in the original post from the [Main Data Query] or is it from [MAIN DATA]?
Can you post the SQL of [Main Data Query] so we can understand better what's going on.
- SELECT [Main Data].SSAN,
-
[Main Data].RANK,
-
[Main Data].SUPER,
-
[Main Data].NAME,
-
[Main Data].[OFF SYM],
-
[Main Data].[Type Award],
-
[Main Data].[Date DECOR Received],
-
[Main Data].[Date DECOR to 9RW],
-
[Main Data].[Date DECOR RTD for Correction],
-
[Main Data].[Date DECOR to MPF],
-
[Main Data].[Date RIP DECOR received and sent],
-
[Main Data].[Date DECOR due to SGS],
-
[Main Data].[DECOR Susp to MPF]
-
FROM [Main Data] INNER JOIN [Main Data] AS [Main Data_1]
-
ON [Main Data].SUPER = [Main Data_1].SSAN
-
WHERE ((([Main Data].SUPER)=
-
DLookUp("[NAME]",
-
"Main Data",
-
"SSAN='" & [SUPER] & "'")
The original post is from Main Data
NeoPa 32,556
Expert Mod 16PB
I'm not sure exactly where we are atm but I'm sure the SQL you've posted doesn't work (After displaying it visibly).
Firstly, the parentheses in your WHERE clause are not balanced.
Sendly, the whole WHERE clause is nonsense (sorry to be stark about it).
The good news is that you can just drop it completely. The SQL up to that point is perfect (As far as I know from what I do know of your data).
NeoPa 32,556
Expert Mod 16PB
...Except that while you've linked perfectly to the matching record of the SUPER you haven't actually selected any field from that record to show.
An extra line should do the trick, in the SELECT clause : - [Main Data_1].NAME AS SuperName,
Leaving SQL for your [Main Data Query] of : - SELECT [Main Data].SSAN,
-
[Main Data].RANK,
-
[Main Data].SUPER,
-
[Main Data].NAME,
-
[Main Data_1].NAME AS SuperName,
-
[Main Data].[OFF SYM],
-
[Main Data].[Type Award],
-
[Main Data].[Date DECOR Received],
-
[Main Data].[Date DECOR to 9RW],
-
[Main Data].[Date DECOR RTD for Correction],
-
[Main Data].[Date DECOR to MPF],
-
[Main Data].[Date RIP DECOR received and sent],
-
[Main Data].[Date DECOR due to SGS],
-
[Main Data].[DECOR Susp to MPF]
-
FROM [Main Data] INNER JOIN [Main Data] AS [Main Data_1]
-
ON [Main Data].SUPER = [Main Data_1].SSAN
That worked perfectly; thank you very much.
On another note: How can I set MAIN DATA Table to update automatically with the DOWNLOAD (linked excel sheet) table?
NeoPa 32,556
Expert Mod 16PB
Not a problem. I'm pleased that helped.
On the other note, You should post this as a new thread as it's not really connected with the question asked in this one.
I expect you'll need to phrase it more clearly though, explaining exactly what you need help with.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Fred |
last post by:
Hi.
How do I import while mapping an excel table to an access table please???
I've searched around and all I can find is a software product or code that
does the same thing as the access...
|
by: JSMiami |
last post by:
I have a form that is fed by a certain table. This table connects to
an intermeddiate table and then a look up table. All of this is done
to accomplish a many-to-many relationship. Imagine that the...
|
by: Leinad Kong |
last post by:
I'm using Access 2002, as front-end and back-end as well:
1) I faced database corrupted problems, when more than 1 user edit
concurrently.
I'm using All-records Locking, and open-exclusively as...
|
by: Alan Lane |
last post by:
Hello world:
Background:
Yesterday, January 21, Doug Steele was kind enough to help me out on a Left
Join problem. I was trying to return all stores and their Gross Adds for
December, 2004...
|
by: Cary |
last post by:
This may reveal my poor programming skills, but here goes...
I'm building a pricing tool for my business. I'm nearing the end of the
project, and I've been asked to be able to save quotes in some...
|
by: Steve |
last post by:
One of our clients recently upgraded their Office version to 2003. When
they tried to run our program (written in Access 2000), they ended up
with the wrong data. My coworker and I have tested this...
|
by: Selva Chinnasamy |
last post by:
Hi I am using batch commands against Ms-Access and getting an error
Message "Characters found after end of SQL statement." String
Here is my sql Dim str_screens As String = "Select * from Screens...
|
by: alexandre.brisebois |
last post by:
Hi, I am using access 2003, I would like to know if there is an option
to reorganize the tables in a maner that is readable, as we can do in
sql sever 2000 or 2005.
I have been given a database...
|
by: Richard |
last post by:
Hi folks, thanks for taking the time to read this (and hopefully point
our where I'm going wrong).
The scenario:
I have a local Access2007 database which links in several read only
mySql...
|
by: hyperpau |
last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding.
I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com).
Ergo, I...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
| |