M
magmike
I am trying to set up a button, that onClick will determine which
report to use, based on a combo box on the form.
THE FORM: ItemsSent - the data source of this form is the table
ItemsSent which stores the different pieces of collateral sent to each
contact. One of the fields in the table ItemsSent (and on the form) is
ItemID.
ItemID is from the table Items which stores the different items that
could be sent. Some of these items are PDF files, others are just hard
collateral. Yet, others are reports in the database that are basically
form letters. For these letters (or reports - which uses contact data
to personalize the letter) there is a field titled ItemReportName
which refers to the exact title of the report.
On the ItemsSent form, the user selects the item from a combo box (the
source of the combo box is ItemID, but shows the name associated with
that record) that they sent or want to send. If a letter is selected,
I want them to be able to click the Send Letter button, behind which
is the following code:
Private Sub SendReport_Click()
Dim stDocName As String
Dim stLinkCriteria As String
stLinkCriteria = "[ItemsSentID]=" & Me![ItemsSentID]
stDocName = [ItemReportName]
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria
Exit_SendReport_Click:
Exit Sub
Err_SendReport_Click:
MsgBox Err.Description
Resume Exit_SendReport_Click
End Sub
However, because only the ItemID is stored in the table, I'm getting
an error stating that it can't find the report "13" (lol!). I can get
it to show the name that goes along with that ID, but I can't get it
to use it when deciding which report to use based on the code.
What am I doing wrong?
Thanks!
magmike
report to use, based on a combo box on the form.
THE FORM: ItemsSent - the data source of this form is the table
ItemsSent which stores the different pieces of collateral sent to each
contact. One of the fields in the table ItemsSent (and on the form) is
ItemID.
ItemID is from the table Items which stores the different items that
could be sent. Some of these items are PDF files, others are just hard
collateral. Yet, others are reports in the database that are basically
form letters. For these letters (or reports - which uses contact data
to personalize the letter) there is a field titled ItemReportName
which refers to the exact title of the report.
On the ItemsSent form, the user selects the item from a combo box (the
source of the combo box is ItemID, but shows the name associated with
that record) that they sent or want to send. If a letter is selected,
I want them to be able to click the Send Letter button, behind which
is the following code:
Private Sub SendReport_Click()
Dim stDocName As String
Dim stLinkCriteria As String
stLinkCriteria = "[ItemsSentID]=" & Me![ItemsSentID]
stDocName = [ItemReportName]
DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria
Exit_SendReport_Click:
Exit Sub
Err_SendReport_Click:
MsgBox Err.Description
Resume Exit_SendReport_Click
End Sub
However, because only the ItemID is stored in the table, I'm getting
an error stating that it can't find the report "13" (lol!). I can get
it to show the name that goes along with that ID, but I can't get it
to use it when deciding which report to use based on the code.
What am I doing wrong?
Thanks!
magmike