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

Home Posts Topics Members FAQ

Convert nickname to fullname when querying data

52 New Member
I have a table of providers that has a license number and fullname field, among others. Deman helped me with being able to enter a nickname and having it change to the fullname if a nickname exists in a nickname table when I have new entries. I also have a table called TA where I enter requests, linking to the providers table with the license number. (The fullname field exists only in the providers table.) I'd like to be able to query the TA table for requests by entering the nickname (as it exists in the nickname table) rather than entering the fullname. Can anyone help? Thanks in advance.
May 23 '07 #1
13 3298
NeoPa
32,556 Recognized Expert Moderator MVP
You should be able to do this in a query after linking the tables in the relevant way. Your question is not currently clear enough to provide a direct answer.
If you post the table Meta-Data we can probably get you further with this.
Here is an example of how to post table MetaData :
Table Name=tblStudent
Expand|Select|Wrap|Line Numbers
  1. Field; Type; IndexInfo
  2. StudentID; AutoNumber; PK
  3. Family; String; FK
  4. Name; String
  5. University; String; FK
  6. Mark; Numeric
  7. LastAttendance; Date/Time
You will need to post (in this format please) for all the tables that link the data you need together.
May 25 '07 #2
CindySue
52 New Member
I'm sorry, I'm pretty much a novice. I'm not sure I understand about Meta-data. Is this it?

I have three tables, by the way:

Table Name=[Licensed Providers]
Expand|Select|Wrap|Line Numbers
  1. Field; Type; IndexInfo
  2. License No;Text;PK
  3. Admin Agency;Text
  4. and some other fields
Table Name = Nicknames
Expand|Select|Wrap|Line Numbers
  1. Field; Type; IndexInfo
  2. Nickname;Text;PK
  3. Admin Agency;Text
  4. these are the only two fields
Table Name = TA
Expand|Select|Wrap|Line Numbers
  1. Field; Type; IndexInfo
  2. License No;Text (this is the same as the Providers table)
  3. and some other fields.
I've created several entries in the nicknames table where I have a short abbreviation in the nickname field and then the full name in the Admin Agency field. For example, doe for the nickname and Department of Education for the Admin Agency field.

When I enter a new Licensed Provider, I can either enter the full name in the Admin Agency field or an abbreviation (or nickname) and if an entry exists for that nickname in the nicknames table it will change that entry to the full name, or leave it as typed if one doesn't exist. I'd like to be able to use this same thing in a query.

My query has both the Providers table and TA table, linked by the license number field. I can enter a part of the Admin Agency name (such as dep or edu) and it will look up records where the Department of Education is the Admin Agency. I would like to be able to enter either a part of the Admin Agency name or the nickname as it exists in the nickname table and find records. If it would be easier to have an extra field in the query that would be OK. I'll know ahead of time whether I want to look up by partial name or nickname, so if it would be easier to do with two separate queries, that would be fine.

Does that make more sense? Thanks so much. I really appreciate the help.
May 25 '07 #3
NeoPa
32,556 Recognized Expert Moderator MVP
It does (sort of) make sense.
My confusion now is how you're typing in a search string. You talk of running a (presumably SELECT) query, but there's no mention of a form or other such method of filtering or searching.
The SQL can be created for linking in the NickName stuff, but I'd need a better understanding of what you're doing with it to know what to suggest.
A good start would be to post the SQL of your current query. Please DO use the [code] tags (#) provided. It saves me the job of adding them for you afterwards ;)
May 25 '07 #4
CindySue
52 New Member
Here's my query code: ( I hope this is what you mean by code tags)

Expand|Select|Wrap|Line Numbers
  1. SELECT TA.[License No],
  2.        [Licensed Providers].[Admin Agency],
  3.        TA.[Type TA],
  4.        TA.Consultant,
  5.        TA.[Date Received],
  6.        TA.[Date to RC],
  7.        TA.[Date Assigned],
  8.        TA.[Reason 1],
  9.        TA.[Reason 2],
  10.        TA.[Date Scheduled],
  11.        TA.[Date Completed],
  12.        TA.[Requested By CCLS],
  13.        TA.[Sent to CCLS],
  14.        TA.Comments
  15. FROM [Licensed Providers] INNER JOIN TA
  16.   ON [Licensed Providers].[License No] = TA.[License No]
  17. WHERE ((([Licensed Providers].[Admin Agency]) Like "*" & [Enter Partial Admin Agency Name] & "*")
  18.   AND  ((TA.[Date Completed]) Is Null));
I've got a form that is attached to the query.

I'm opening the form, which in turn starts the query which asks me to enter a partial agency name. When I do that, the records are displayed in the form. Thanks for helping me. I realize I'm terribly inadequate in providing the information in the proper form.
May 25 '07 #5
NeoPa
32,556 Recognized Expert Moderator MVP
To add [code] tags to your post, simply select all the text that is code, then click on the graphic above the message you're typing, which looks like a hash (#). This will put [code] tags around the selected text for you. I fixed your last post for you, don't worry.

I will have to look at your question again later in the weekend as it's after 23:00 here atm and I'm getting tired.
May 25 '07 #6
NeoPa
32,556 Recognized Expert Moderator MVP
First lets deal with tidying up some things to make life easier for ourselves.
I've simplified usage of the [Licensed Providers] table with a pseudonym LP. This makes it easier to work with and understand at a glance. I assume that your table MetaData is the incorrect version and that the actual name of the [Providers] table is [Licensed Providers]. I've edited your post to reflect this.
I've changed the strings to use the more correct quote (') within SQL.
Expand|Select|Wrap|Line Numbers
  1. SELECT TA.[License No],
  2.        LP.[Admin Agency],
  3.        TA.[Type TA],
  4.        TA.Consultant,
  5.        TA.[Date Received],
  6.        TA.[Date to RC],
  7.        TA.[Date Assigned],
  8.        TA.[Reason 1],
  9.        TA.[Reason 2],
  10.        TA.[Date Scheduled],
  11.        TA.[Date Completed],
  12.        TA.[Requested By CCLS],
  13.        TA.[Sent to CCLS],
  14.        TA.Comments
  15. FROM ([Licensed Providers] AS LP
  16.      INNER JOIN TA
  17.   ON LP.[License No]=TA.[License No])
  18.      INNER JOIN NickNames AS NN
  19.   ON LP.[Admin Agency]=NN.[Admin Agency]
  20. WHERE ((TA.[Date Completed]) Is Null)
  21.   AND  ((LP.[Admin Agency] Like '*' & [Enter Partial Admin Agency Name (or NickName)] & '*')
  22.    OR   (NN.Nickname Like '*' & [Enter Partial Admin Agency Name (or NickName)] & '*'));
Now to the changes more relevant to your particular issue :
First of all you need to link in the extra table (See the FROM clause).
Now you need to change the WHERE clause to include a check for the Nickname. This should be ORed with the other name check, but together these checks should be ANDed with the date check.

I have made the assumption here that all [Admin Agency]s have associated Nicknames. If that is not true then this will not work as expected and some further changes will be required.
May 26 '07 #7
CindySue
52 New Member
Thanks so very much for your help. The Admin Agencies do not all have nicknames. Nicknames only exist for some of the longer ones or the ones most frequently used.
May 29 '07 #8
NeoPa
32,556 Recognized Expert Moderator MVP
Thanks so very much for your help. The Admin Agencies do not all have nicknames. Nicknames only exist for some of the longer ones or the ones most frequently used.
OK, but I'll have to come back to this tomorrow (or later today if I'm lucky).
If I haven't replied by tomorrow morning, then bumb the thread to re-add it to my list for tomorrow.
For future reference, that would have been handy to know before-hand ;)
May 29 '07 #9
NeoPa
32,556 Recognized Expert Moderator MVP
Thanks so very much for your help. The Admin Agencies do not all have nicknames. Nicknames only exist for some of the longer ones or the ones most frequently used.
The JOIN is changed and the Nz() function is used to handle unwanted Nulls.
Expand|Select|Wrap|Line Numbers
  1. SELECT TA.[License No],
  2.        LP.[Admin Agency],
  3.        TA.[Type TA],
  4.        TA.Consultant,
  5.        TA.[Date Received],
  6.        TA.[Date to RC],
  7.        TA.[Date Assigned],
  8.        TA.[Reason 1],
  9.        TA.[Reason 2],
  10.        TA.[Date Scheduled],
  11.        TA.[Date Completed],
  12.        TA.[Requested By CCLS],
  13.        TA.[Sent to CCLS],
  14.        TA.Comments
  15. FROM ([Licensed Providers] AS LP
  16.      INNER JOIN TA
  17.   ON LP.[License No]=TA.[License No])
  18.      LEFT JOIN NickNames AS NN
  19.   ON LP.[Admin Agency]=NN.[Admin Agency]
  20. WHERE ((TA.[Date Completed]) Is Null)
  21.   AND  ((LP.[Admin Agency] Like '*' & [Enter Partial Admin Agency Name (or NickName)] & '*')
  22.    OR   (Nz(NN.Nickname,'') Like '*' & [Enter Partial Admin Agency Name (or NickName)] & '*'));
May 30 '07 #10
CindySue
52 New Member
I'm terriby sorry, but I'm not getting any results from the query. I copied the query info and pasted it into SQL view. I copied the Licensed Providers and Nicknames tables and named them LP and NN so the names would be the same. In LP I deleted all but 6 records. In TA I deleted all but 10 entries, using each license number from the LP table once and one four times. I used Dept. of Education as the Admin Agency in the LP table, and it exists exactly the same (I copied and pasted to be sure) in the NN table, with doe as the nickname. When I query I can't get any results at all, either from a nickname or from a partial name.
May 30 '07 #11
NeoPa
32,556 Recognized Expert Moderator MVP
The table names I used were the ones you provided. The query simply uses aliases, that's all. The SQL code was designed to copy and paste straight into a QueryDef's SQL view.
What do you mean you copied the tables?
What do you have in the way of tables now?
May 30 '07 #12
CindySue
52 New Member
I didn't understand about the aliases, so since I didn't have tables with those names I copied the Licensed Providers table and named it LP and copied the Nicknames table and called it NN. I also complicated things when I didn't make sure the date completed field was null in my practice data. I put their names back and made sure the date completed field is empty, and it seems to be working now. I REALLY appreciate all your patience and effort. Thank you so very much.
May 30 '07 #13
NeoPa
32,556 Recognized Expert Moderator MVP
Not a problem :) I'm glad it worked when you 'reverted'.
Wherever you see the keyword AS in SQL it indicates that the preceeding expression is to be named as the succeeding name.
Tables can get this treatment, but so can fields and more complicated expressions (including sub-queries, but let's not go there for now :D). It can also be written by simply forgetting the AS keyword, but It's my practice never to do that, as it's more confusing to read and understand.
May 30 '07 #14

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

Similar topics

11
by: jguilford | last post by:
I have created a SQL Stored Procedure that uses a Case statement to determine the Order By. For one of the Case statements I am trying to turn a Char field into Datetime in for the Order By,...
0
by: aj | last post by:
DB2 WSE LUW 8.1 Fixpak 5 Red Hat AS 2.1 I'm trying to set up a federated view from one DB2 database to another in the same instance on the same server. I do a: create server <SERVER> type...
9
by: Kurt | last post by:
Hi I was trying to get this VB type code to work in C Sub SetColumns_Example( Dim ol As Outlook.Applicatio Dim MyFolder As MAPIFolde Dim itms As Item Dim itm As Objec Dim dtmStart As Date,...
5
by: Jiggaz | last post by:
Hi, Look my stored procedure : __________________ ALTER PROCEDURE dbo.CreateAccount @Nickname varchar(30), @Password varchar(15), @Email varchar(50), @Date datetime,
1
by: Mark Hollander | last post by:
Hi All, Could you please help me convert this code so that it will run in VB.NET Thank You Mark Hollander Private Type USER_INFO Name As String
3
by: Jean-Marc Blaise | last post by:
Hi, Is there any reason why a CREATE NICKNAME statement fails if the remote object is an ALIAS ? I actually have an ALIAS that is used to point to the correct table in the remote DB, and...
7
by: Arun Srinivasan | last post by:
I have a problem, I am getting SQL1042N The SQL statement is not supported. error when I try to create a MQT against a nickname. The source db is db2 version 9.1 fixpack 4, same as the target db...
4
by: Arun Srinivasan | last post by:
I need to create an MQT on a nickname, the requirement is that I need to transfer data from source to target when required (this is because the nickname is slow - i can't implement required indices...
9
by: myotheraccount | last post by:
Hello, Is there a way to convert a DataRow to a StringArray, without looping through all of the items of the DataRow? Basically, I'm trying to get the results of a query and put them into a...
0
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
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,...
1
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
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
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
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.