Two Criteria

D

Dan @BCBS

Background: My form has a subform each have seperate tables. The subform is
for multiple entries linked to the main form/record. The challenge started
with the need to generate letters (reports). In a text box, in the letter, I
coded some conditions like:" & IIf([CA_NAME]="IR","Internal Review
Committee"). I also needed to allow the user to enter data that would appear
on the letter (report) so I created a form from a new table. The user enters
the data in this new form which is linked to the record. Note: The Letter
(report) is made from a query that has all three tables.

The problem is, when I print the letter, it prints a copy for every entry on
the subform.
So I added a date field on the form that the user enters the date related to
the subform entry and I am trying to link that date so it will only print the
information based on that one subform entry.
I hope this is not too confusing.

Bottom line, my print button criteria needs to have two criteria:
1. stLinkCriteria = "[ICNNO]=" & "'" & ICNNO & "'"
2. stLinkCriteria2 = "[CA_DATEFRWD]=" & "'" & CA_DATEFRWD & "'"

But even with this I still get a print for every subform entry.

Please help!
 
M

Marshall Barton

Dan @BCBS said:
Background: My form has a subform each have seperate tables. The subform is
for multiple entries linked to the main form/record. The challenge started
with the need to generate letters (reports). In a text box, in the letter, I
coded some conditions like:" & IIf([CA_NAME]="IR","Internal Review
Committee"). I also needed to allow the user to enter data that would appear
on the letter (report) so I created a form from a new table. The user enters
the data in this new form which is linked to the record. Note: The Letter
(report) is made from a query that has all three tables.

The problem is, when I print the letter, it prints a copy for every entry on
the subform.
So I added a date field on the form that the user enters the date related to
the subform entry and I am trying to link that date so it will only print the
information based on that one subform entry.
I hope this is not too confusing.

Bottom line, my print button criteria needs to have two criteria:
1. stLinkCriteria = "[ICNNO]=" & "'" & ICNNO & "'"
2. stLinkCriteria2 = "[CA_DATEFRWD]=" & "'" & CA_DATEFRWD & "'"

Combine two criteria with AND:

stLinkCriteria = "[ICNNO]='" & ICNNO _
& "' And [CA_DATEFRWD]='" & CA_DATEFRWD & "' "
 
D

Dan @BCBS

I appreciate the help.
This is what I ended up with and it works fine:

tDocName = "r_LetterAck1"

stLinkCriteria = "[ICNNO]='" & ICNNO _
& "' And [tblCaseLog].[CA_DATEFRWD]=#" & Me.CA_DATEFRWD & "# "

DoCmd.OpenReport stDocName, acPrint, , stLinkCriteria




Marshall Barton said:
Dan @BCBS said:
Background: My form has a subform each have seperate tables. The subform is
for multiple entries linked to the main form/record. The challenge started
with the need to generate letters (reports). In a text box, in the letter, I
coded some conditions like:" & IIf([CA_NAME]="IR","Internal Review
Committee"). I also needed to allow the user to enter data that would appear
on the letter (report) so I created a form from a new table. The user enters
the data in this new form which is linked to the record. Note: The Letter
(report) is made from a query that has all three tables.

The problem is, when I print the letter, it prints a copy for every entry on
the subform.
So I added a date field on the form that the user enters the date related to
the subform entry and I am trying to link that date so it will only print the
information based on that one subform entry.
I hope this is not too confusing.

Bottom line, my print button criteria needs to have two criteria:
1. stLinkCriteria = "[ICNNO]=" & "'" & ICNNO & "'"
2. stLinkCriteria2 = "[CA_DATEFRWD]=" & "'" & CA_DATEFRWD & "'"

Combine two criteria with AND:

stLinkCriteria = "[ICNNO]='" & ICNNO _
& "' And [CA_DATEFRWD]='" & CA_DATEFRWD & "' "
 

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