Hi,
I am using the following code to print a letter based off a current record on a form:
strReportName = "Candidacy"
strCriteria = "[DatabaseID]=" & Me![DatabaseID]
MsgBox "Load 1 sheet of Official Letterhead, then OK to continue"
DoCmd.OpenReport strReportName, acViewPreview, , strCriteria
That brings up the print preview and we can print that off. However, we want to print directly and not use that step and would like to just print with
DoCmd.OpenReport strReportName, , , strCriteria
When I do that though, the field that I created to format their address does not print at all. It is an unbound field. I will display the code before but it appears that the unbound field is the problem. All other fields are printed.
On the report, I have hidden fields that include city, state, zip, etc and then an unbound field that puts them together with the proper formatting. It also has an if statement that checks to see if it should use the permanent address fields or the current address fields. When I use the print preview option, it works fine, but it's blank if I try to print directly.
Any suggests to fix this would be greatly appreciated! Thanks!
-----this is my Report_Load subroutine on the report in question
Private Sub Report_Load()
If [SameAsPerm] Then
Add1 = [Permanent Address 1]
If IsNull([Permanent Address 2]) Or [Permanent Address 2] = "" Then
NeedAdd2 = False
Else
NeedAdd2 = True
Add2 = [Permanent Address 2]
End If
City = [Permanent City]
State = [Permanent State]
Zip = [Permanent Zip]
Country = [Permanent Country]
If Country = "USA" Or Country = "US" Then
NeedToSetCountry = False
Else
NeedToSetCountry = True
End If
Else
Add1 = [Current Address 1]
If IsNull([Current Address 2]) Or [Current Address 2] = "" Then
NeedAdd2 = False
Else
NeedAdd2 = True
Add2 = [Current Address 2]
End If
City = [Current City]
State = [Current State]
Zip = [Current Zip]
NeedToSetCountry = False
End If
FullAddress = Add1
If NeedAdd2 Then
FullAddress = FullAddress & vbCrLf & Add2
End If
FullAddress = FullAddress & vbCrLf & City & ", " & State & " " & Zip
If NeedToSetCountry Then
FullAddress = FullAddress & vbCrLf & Country
End If
txtAddress = FullAddress
End Sub