Help with labels

  • Thread starter Thread starter DebbieG
  • Start date Start date
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
 
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
 
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
 
Back
Top