Simple procedure is alluding me...

M

magmike

I just want a button that inserts text into a field, before opening a
report.

Here's the details:

THE FORM, titled ItemsSent is for sending letters and capturing the
text of those letters into a table relating to the company the letter
was sent to. The two fields in question here are ItemsSent.Notes and
ItemsSent.LetterCopy. There is also a subform on the form that shows
anyother listings for this company in the past, and that subform has
the Notes field as well.

THE COMMAND BUTTON, is meant to be pushed, and when pushed, inserts
text into the ItemsSent.Notes field ("Blank Letterhead used with
LetterCopy") and then runs code to open the report which is a
formatted letter using the data from the record.

THE PROBLEM - even though my code instructs to insert text into the
Notes field, it inserts it into the LetterCopy field. Both fields are
memo fields. Also, I notice in the code, that it automatically changes
Notes into all capitals (NOTES).

THE CODE:

Private Sub PrintBlankLetter_Click()

Dim stDocName As String
Dim stLinkCriteria As String

NOTES.SetFocus
NOTES.Text = "Blank Letterhead used with LetterCopy"

DoCmd.Requery
DoCmd.Minimize

stLinkCriteria = "[ItemsSentID]=" & Me![ItemsSentID]
stDocName = "Blank Letter"
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria

Exit_PrintBlankLetter_Click:
Exit Sub

Err_PrintBlankLetter_Click:
MsgBox Err.Description
Resume Exit_PrintBlankLetter_Click
End Sub

Thanks in advance!

magmike
 
G

Guest

Where are you seeing it in the wrong field? On your form or in your report?
The first thing that came to mind was to make sure that the controlsource of
your notes textbox was in fact the notes field.

The changing "Notes" to "NOTES" is probably just because the control was
named in all caps instead of mixed case. It will automatically change it to
match.
 
M

magmike

Where are you seeing it in the wrong field? On your form or in your report?
The first thing that came to mind was to make sure that the controlsource of
your notes textbox was in fact the notes field.

The changing "Notes" to "NOTES" is probably just because the control was
named in all caps instead of mixed case. It will automatically change it to
match.



magmike said:
I just want a button that inserts text into a field, before opening a
report.
Here's the details:
THE FORM, titled ItemsSent is for sending letters and capturing the
text of those letters into a table relating to the company the letter
was sent to. The two fields in question here are ItemsSent.Notes and
ItemsSent.LetterCopy. There is also a subform on the form that shows
anyother listings for this company in the past, and that subform has
the Notes field as well.
THE COMMAND BUTTON, is meant to be pushed, and when pushed, inserts
text into the ItemsSent.Notes field ("Blank Letterhead used with
LetterCopy") and then runs code to open the report which is a
formatted letter using the data from the record.
THE PROBLEM - even though my code instructs to insert text into the
Notes field, it inserts it into the LetterCopy field. Both fields are
memo fields. Also, I notice in the code, that it automatically changes
Notes into all capitals (NOTES).
THE CODE:
Private Sub PrintBlankLetter_Click()
Dim stDocName As String
Dim stLinkCriteria As String
NOTES.SetFocus
NOTES.Text = "Blank Letterhead used with LetterCopy"
DoCmd.Requery
DoCmd.Minimize

stLinkCriteria = "[ItemsSentID]=" & Me![ItemsSentID]
stDocName = "Blank Letter"
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria
Exit_PrintBlankLetter_Click:
Exit Sub
Err_PrintBlankLetter_Click:
MsgBox Err.Description
Resume Exit_PrintBlankLetter_Click
End Sub
Thanks in advance!
magmike- Hide quoted text -

- Show quoted text -

I figured out the problem. Dang I'm stupid! I was using the name of
the control source, but I never named the form control. I changed the
code from "Notes" to "Text15" and now it works.
 

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