databasedonr
Registered User.
- Local time
- Today, 14:13
- Joined
- Feb 13, 2003
- Messages
- 163
Greetings all:
I have a challenge for extracting phone numbers.
I have a database with mulitple tables, one of which is tblcontact and another a tblphone.
In my tblcontact I have fields like: contactid, lastname, firstname etc.
In tblphone I have phoneid, contactid, phonetype and phonenumber.
In the phonetype field are text strings like: "Business", "Pager", "Email" and "Cell"; the phonenumber field has the appropriate data for the type. This means I have up to 4 rows in my tblphone for a contact.
When I retrieve these records, I want to display them in both form and a report as four (or less) fields on one row.
For example, if my contactid is 12345, I have rows for each type of phone in the phone table (up to four). I want this to display as:
Contact Business Email Cell
databasedonr 123-4567 donr@access.ca 132-6547
Please help! I'm really at a loss for how to do this: I have tried creating expressions based on the phonetype, but can only get it to work for one phonetype.
I have also tried writing a subquery as follows, and this tells me that I can only return one row of data.
Some of the fabulous expertise from this forum, I hope, will help me solve this problem.
Here's the subquery I tried:
SELECT [tblcontact].[lastname], [tblcontact].[firstname], (SELECT[phonenumber]FROM [tblphone]where[phonetype]="Email") AS Email
FROM tblPhone INNER JOIN tblContact ON [tblPhone].[ContactID]=[tblContact].[ContactID]
WHERE ((([tblcontact].[lastname])="[User Input]") And (([tblcontact].[firstname])="[User Input]"))
ORDER BY [tblcontact].[lastname], [tblcontact].[firstname];
Any suggestions hugely appreciated:
Thanks in advance.
I have a challenge for extracting phone numbers.
I have a database with mulitple tables, one of which is tblcontact and another a tblphone.
In my tblcontact I have fields like: contactid, lastname, firstname etc.
In tblphone I have phoneid, contactid, phonetype and phonenumber.
In the phonetype field are text strings like: "Business", "Pager", "Email" and "Cell"; the phonenumber field has the appropriate data for the type. This means I have up to 4 rows in my tblphone for a contact.
When I retrieve these records, I want to display them in both form and a report as four (or less) fields on one row.
For example, if my contactid is 12345, I have rows for each type of phone in the phone table (up to four). I want this to display as:
Contact Business Email Cell
databasedonr 123-4567 donr@access.ca 132-6547
Please help! I'm really at a loss for how to do this: I have tried creating expressions based on the phonetype, but can only get it to work for one phonetype.
I have also tried writing a subquery as follows, and this tells me that I can only return one row of data.
Some of the fabulous expertise from this forum, I hope, will help me solve this problem.
Here's the subquery I tried:
SELECT [tblcontact].[lastname], [tblcontact].[firstname], (SELECT[phonenumber]FROM [tblphone]where[phonetype]="Email") AS Email
FROM tblPhone INNER JOIN tblContact ON [tblPhone].[ContactID]=[tblContact].[ContactID]
WHERE ((([tblcontact].[lastname])="[User Input]") And (([tblcontact].[firstname])="[User Input]"))
ORDER BY [tblcontact].[lastname], [tblcontact].[firstname];
Any suggestions hugely appreciated:
Thanks in advance.