Help with labels

D

DebbieG

I'm having trouble with some labels that I have created for a client that
reports information to the Department of Education.

Here are my tables:

Students --
SSN
LastNM
FirstNM

Addresses --
SSN
PrintCheck
Address1
Address2
City
State
ZipCode
ParentPrintCheck
ParentAddress1
ParentAddress2
ParentCity
ParentState
ParentZipCode

I have a query that joins these two tables.

Then I have a form that uses the query that displays the Student's name,
PrintCheck, Student's Address, ParentPrintCheck, and the Parent's Address.
The user can only select one address for each student. A command button
runs the report. Here's the code behind the report (labels):

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.PrintCheck = -1 Then
Me.txtAddress1 = Me.Address1
Me.txtAddress2 = Me.Address2
Me.txtCityStateZip = Me.CityStateZip
ElseIf Me.ParentPrintCheck = -1 Then
Me.txtAddress1 = Me.ParentAddress1
Me.txtAddress2 = Me.ParentAddress2
Me.txtCityStateZip = Me.ParentCityStateZip
End If
End Sub

This works great EXCEPT if they don't want to choose either address, it
prints the Student's Name without an address. How can I get it to skip that
Student entirely if they don't choose either PrintCheck box?

It's probably something very simple but I'm not coming up with it. If you
need further information, please let me know -- I tried to keep this as
brief as possible.

Thanks in advance for any help,
Debbie
 
M

Marshall Barton

DebbieG said:
I'm having trouble with some labels that I have created for a client that
reports information to the Department of Education.

Here are my tables:

Students --
SSN
LastNM
FirstNM

Addresses --
SSN
PrintCheck
Address1
Address2
City
State
ZipCode
ParentPrintCheck
ParentAddress1
ParentAddress2
ParentCity
ParentState
ParentZipCode

I have a query that joins these two tables.

Then I have a form that uses the query that displays the Student's name,
PrintCheck, Student's Address, ParentPrintCheck, and the Parent's Address.
The user can only select one address for each student. A command button
runs the report. Here's the code behind the report (labels):

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.PrintCheck = -1 Then
Me.txtAddress1 = Me.Address1
Me.txtAddress2 = Me.Address2
Me.txtCityStateZip = Me.CityStateZip
ElseIf Me.ParentPrintCheck = -1 Then
Me.txtAddress1 = Me.ParentAddress1
Me.txtAddress2 = Me.ParentAddress2
Me.txtCityStateZip = Me.ParentCityStateZip
End If
End Sub

This works great EXCEPT if they don't want to choose either address, it
prints the Student's Name without an address. How can I get it to skip that
Student entirely if they don't choose either PrintCheck box?


I think all you need to do is add the WhereCondition
argument to the code in the print button's Click event
procedure. The code will end up looking something like:

Dim strDoc As String
Dim strCriteria As String

strDoc = "nameofreport"
strCriteria = "PrintCheck = -1 OR ParentPrintCheck = -1"
DoCmd.OpenReport strDoc, , , strCriteria
 
D

DebbieG

Marsh,

That did it! Thank you so much for taking your time to help me.

Debbie


DebbieG said:
I'm having trouble with some labels that I have created for a client that
reports information to the Department of Education.

Here are my tables:

Students --
SSN
LastNM
FirstNM

Addresses --
SSN
PrintCheck
Address1
Address2
City
State
ZipCode
ParentPrintCheck
ParentAddress1
ParentAddress2
ParentCity
ParentState
ParentZipCode

I have a query that joins these two tables.

Then I have a form that uses the query that displays the Student's name,
PrintCheck, Student's Address, ParentPrintCheck, and the Parent's Address.
The user can only select one address for each student. A command button
runs the report. Here's the code behind the report (labels):

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.PrintCheck = -1 Then
Me.txtAddress1 = Me.Address1
Me.txtAddress2 = Me.Address2
Me.txtCityStateZip = Me.CityStateZip
ElseIf Me.ParentPrintCheck = -1 Then
Me.txtAddress1 = Me.ParentAddress1
Me.txtAddress2 = Me.ParentAddress2
Me.txtCityStateZip = Me.ParentCityStateZip
End If
End Sub

This works great EXCEPT if they don't want to choose either address, it
prints the Student's Name without an address. How can I get it to skip that
Student entirely if they don't choose either PrintCheck box?


I think all you need to do is add the WhereCondition
argument to the code in the print button's Click event
procedure. The code will end up looking something like:

Dim strDoc As String
Dim strCriteria As String

strDoc = "nameofreport"
strCriteria = "PrintCheck = -1 OR ParentPrintCheck = -1"
DoCmd.OpenReport strDoc, , , strCriteria
 

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

Similar Threads

Correct sort 9

Top