Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dear Sir if letter is going to a Company

Status
Not open for further replies.

DIRENE

Technical User
Jan 19, 2004
51
US
I have a report rptFirstLetter that has a textbox for full name that pulls off a query that

FullName: StrConv([FIRSTName] & " " & [LASTName] & " " & [companyname],3)

On the report I have a textbox that has a control source of
="Dear" & " " & [fullFirst] & ","

[fullFirst] comes from the query too
FullFirst: StrConv([FIRSTName],3)

Letter will show

Dear Irene

Which work's great if it's a person name but if it's a company I would like the letter to say

Dear Sir

Is there away to do this.

Thank you,

Irene
 
How do you deterine it is a company? Once you know this:

In the query, where you have:

FullFirst: StrConv([FIRSTName],3)

Use:

FullFirst: = IIF([company]=True, "Sir", StrConv([FIRSTName],3))

Or something alosng that lines....let me know. Give some more details of your layout if you need a more specific solution.

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
MCSA, CNA, Net+, A+
w: rljohnso@stewart.com
h: wildmage@tampabay.rr.com
 
I see how your line would work, but I don't know how to put it in to either my query or my report

Ok if I change the field in the query to:
Fullfirst: StrConv([FIRSTName] & " " & [companyname],3)

How would I use your line in the report on the textbox control source that I now have this:

="Dear" & " " & [fullFirst] & ","

If that is posiable
Thank you,

Irene



 
Irene,

Let's take a step back and start again....We are crossing communications and I don't want to confuse you....

The first thing we have to decide is how do you determine a company or a person. How do you distinguish when to use "Dear Robert," Or "Dear Sir,"? Do you have a field somewhere that can be checked against to determine when to use Sir or the name?

Once this is accomplished, all we have to do is check that field and fill in the appropriate info. Can you post your table structure with relevant fields and maybe a couple sample lines of data? This will help me help you find the solution you seek.

****** Example *****
tblCustomers
Name String (primary key)
Company String

Record 1 John Jones ABC Building
Record 2 Mark Williams
Record 3 Barry Bonds XYZ Plumbing
****** Example ******

With the above info, our query would be modified to include the Company field....we don't have to show it, just have it available to the query. And then our FullFirst line would be:

FullFirst: = IIF(IsNull([Company]), StrConv([FIRSTName],3), "Sir")

This would look at the Company field....if it is empty, it would put the first name in the field for you....if the Company field has a name it will put "Sir" in your FullFirst field...You report needs no modification whatsoever, becuase we are adjusting the query to pass the right info to the report.

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
MCSA, CNA, Net+, A+
w: rljohnso@stewart.com
h: wildmage@tampabay.rr.com
 
After I post I reread you post and I got it to work because my table name is really companyname not company. I fixed that and it works great. Thank you so much for all your help. Irene
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top