Creating A Letter

G

Guest

On my table, I have the following fields - Name, Address & Subjects. In the
subjects field I input the subjects of my applicants eg English, Sociology &
History.

I now want to create a letter from this table using a report to say - Thank
you for applying to study "Subjects". You will need the following grades etc
etc.

Is there a way that I can input the Subjects field but carry on with my
sentence? I have tried but I have to start my next sentence on a new line
and so my letter doesnt make sense. I need to insert the subjects and carry
on!

I know you can do this with a mail merge but I would rather just have the
report there on my database.

Any help would be great.

Thanks.
 
B

BruceM

In general it sounds like you need to concatenate text with fields. One way
to do this for a relatively short letter is to use the report's Print event:
Me.txtLetter = "Thank you for applying to study " & [Subjects] & ". You
need the following grades etc."
You could use the same expression (starting from the = sign) in the control
source of an unbound text box.
Before you get too far into the project you may want to reconsider your
design. For one thing, if Name (you should not name the field "Name", by
the way, as it is a reserved word) and Address are contained in just two
fields you lose most of your ability to do any reasonable sorting or
searching. For another, a table should contain information about a single
entity (personal information about a person, or a listing of subjects,
etc.), rather than a combination of different ones. Will you enter the name
and other information from scratch each time you need to send a letter, or
will you modify the subjects each time? Do you want to keep track of what
subjects the person has taken in the past?
 
A

Arvin Meyer [MVP]

By concatenating your text and data, you get exactly what you need. Use a
textbox instead of a label to hold all your text. Set the control source
like:

= "Some varying amount of text ... yada yada " & Me.txtSubjects & " Some
more text ... yada yada."
 
G

Guest

Hi,

Thanks for that.
I just said the fields where Name, Address & Subjects to keep it simple.
It is layed out properly eg Firstname, Surname, Address 1, Addres 2 etc etc

My table will end up as list of 500 people with what subjects they want.
I have to write a letter to each one to say - To study these subjects you
need the following grades" etc

If I need to do a Print Event to show the subjects in a sentence can you
tell me how to do it please? (Iv'e never done this before)

Thanks.

BruceM said:
In general it sounds like you need to concatenate text with fields. One way
to do this for a relatively short letter is to use the report's Print event:
Me.txtLetter = "Thank you for applying to study " & [Subjects] & ". You
need the following grades etc."
You could use the same expression (starting from the = sign) in the control
source of an unbound text box.
Before you get too far into the project you may want to reconsider your
design. For one thing, if Name (you should not name the field "Name", by
the way, as it is a reserved word) and Address are contained in just two
fields you lose most of your ability to do any reasonable sorting or
searching. For another, a table should contain information about a single
entity (personal information about a person, or a listing of subjects,
etc.), rather than a combination of different ones. Will you enter the name
and other information from scratch each time you need to send a letter, or
will you modify the subjects each time? Do you want to keep track of what
subjects the person has taken in the past?

1foxi said:
On my table, I have the following fields - Name, Address & Subjects. In
the
subjects field I input the subjects of my applicants eg English,
Sociology &
History.

I now want to create a letter from this table using a report to say -
Thank
you for applying to study "Subjects". You will need the following grades
etc
etc.

Is there a way that I can input the Subjects field but carry on with my
sentence? I have tried but I have to start my next sentence on a new line
and so my letter doesnt make sense. I need to insert the subjects and
carry
on!

I know you can do this with a mail merge but I would rather just have the
report there on my database.

Any help would be great.

Thanks.
 
B

BruceM

From your most recent posting it sounds as if you have it figured out. If
so, I expect you did so using the Control Source for a text box. People
will tend to assume the literal meaning of what you have written. To avoid
unnecessary commentary I often say something like: "I have fields
FirstName, LastName, Address, City, etc.".

For future reference, here is how to add a Print Event. By the way, I erred
in saying it is a report Event. It is acutally an event for a section
(Header, Footer, Detail). Open the report in design view; click any blank
area in the Detail section (assuming that the text box in which you want the
message to appear is in that section); click View > Properties. Click the
Event tab, and click the white area next to On Print. Click the three dots
that appear; click Code Builder, OK. You should see something like this in
the new window that opens:

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)

End Sub

Click between the two lines and enter the code. It may look something like
this:

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)

Me.txtLetter = "Thank you for applying to study " & [Subjects] & _
". You need the following grades etc."

End Sub

It is a good idea to add some error handling:

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)

On Error GoTo ProcErr

' txtLetter is the text box in which the letter body appears
Me.txtLetter = "Thank you for applying to study " & [Subjects] & _
". You need the following grades etc."

ProcExit:
Exit Sub

ProcErr:
MsgBox "Error #" & Err.Number & ", " & Err.Description & " Detail_Print"
Resume ProcExit

End Sub

Error handling will help you identify problems when they occur, and the
event that generated the error.

This is just a sketch. Events in forms and reports are very useful tools,
but the process can't be summed up in a message. For now just note a few
things. Use your actual field and control names, of course. Give bound
text boxes a different name than the fields to which they are bound. The
underscore in the text of the message:

Me.txtLetter = "Thank you for applying to study " & [Subjects] & _
". You need the following grades etc."

allows you to break the code into lines; otherwise it would just continue to
the right, and you would need to scroll back and forth. The underscore is
preceded by a space. Indents and spaces between lines are irrelevant to the
code, but will make life easier for you. ProcErr and ProcExit are labels
(they are followed by a colon), and need to start at the left margin; other
code may be arranged as you choose.

1foxi said:
Hi,

Thanks for that.
I just said the fields where Name, Address & Subjects to keep it simple.
It is layed out properly eg Firstname, Surname, Address 1, Addres 2 etc
etc

My table will end up as list of 500 people with what subjects they want.
I have to write a letter to each one to say - To study these subjects you
need the following grades" etc

If I need to do a Print Event to show the subjects in a sentence can you
tell me how to do it please? (Iv'e never done this before)

Thanks.

BruceM said:
In general it sounds like you need to concatenate text with fields. One
way
to do this for a relatively short letter is to use the report's Print
event:
Me.txtLetter = "Thank you for applying to study " & [Subjects] & ". You
need the following grades etc."
You could use the same expression (starting from the = sign) in the
control
source of an unbound text box.
Before you get too far into the project you may want to reconsider your
design. For one thing, if Name (you should not name the field "Name", by
the way, as it is a reserved word) and Address are contained in just two
fields you lose most of your ability to do any reasonable sorting or
searching. For another, a table should contain information about a
single
entity (personal information about a person, or a listing of subjects,
etc.), rather than a combination of different ones. Will you enter the
name
and other information from scratch each time you need to send a letter,
or
will you modify the subjects each time? Do you want to keep track of
what
subjects the person has taken in the past?

1foxi said:
On my table, I have the following fields - Name, Address & Subjects.
In
the
subjects field I input the subjects of my applicants eg English,
Sociology &
History.

I now want to create a letter from this table using a report to say -
Thank
you for applying to study "Subjects". You will need the following
grades
etc
etc.

Is there a way that I can input the Subjects field but carry on with my
sentence? I have tried but I have to start my next sentence on a new
line
and so my letter doesnt make sense. I need to insert the subjects and
carry
on!

I know you can do this with a mail merge but I would rather just have
the
report there on my database.

Any help would be great.

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top