Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reports Formatting/Sorting

Status
Not open for further replies.

jswe

MIS
Dec 30, 2003
8
US
Having 2 problesm with reports:
When I distribute application I have a macro setup where users can view reports then print if they want - but I am losing the formatting on different copies of Access97. I thought the page setup (landscape - legal) was saved in the report, but people are pulling up the report and it is in portrait. Once they save in landscape it is OK but can I get it to print/view in landscape the first time.

Also they want different sort options - I setup an option group and wrote a module. But I have been unable to get to the reports sorting and grouping in code. Which has forced me to save multiple copies of the same report changing the sorting on each report. Based on their selection in the option group, I am pulling up a seperate report. I would like to only maintain 1 report and somehow modify the sorting grouping in code. Is this possible.


Thanks
 
Here is code that you can put into your report that will change the sort order at run time with a pop up dialogue box. Since you are using an option group, you will need to modify the code by removing the main part and only leave

Me.OrderBy = MySortField
Me.OrderByOn = True

You will need to change MySortField to refer to the form and option group (Forms!...).

MySortField

This code example sorts on Date, Name, Country and or Office
Put this code in the Close event of the report.

---------------------------------------
Private Sub Report_Close()
' Allow user to change sort order at run time
Dim MySortField As String

MySortField = UCase(InputBox("Please enter one of the following letters to sort on:" & _
vbCrLf & "N to sort by Name" & vbCrLf & "A by Arrival Date" & _
vbCrLf & "O by Office" & vbCrLf & "C by Country" & _
vbCrLf & vbCrLf & "Not entering a letter will sort the report by Name.", "Sort Option"))

If MySortField = "A" Then
MySortField = "ARRIVAL_DATE, FULL_NAME"
Me.lblSortType.Caption = "Sorted by Arrival Date"
ElseIf MySortField = "C" Then
MySortField = "COUNTRY, FULL_NAME"
Me.lblSortType.Caption = "Sorted by Country"
ElseIf MySortField = "O" Then
MySortField = "OFFICE, FULL_NAME"
Me.lblSortType.Caption = "Sorted by Office"
Else
'MsgBox "Sorting By Name", vbOKOnly, "Default Sort"
MySortField = "FULL_NAME"
Me.lblSortType.Caption = "Sorted by Name"
Exit Sub
End If

Me.OrderBy = MySortField
Me.OrderByOn = True

End Sub
----------------------------------------

As for the printer issue, I haven't figured out how to overcome as the report is affected by the default printer setup the user has. I too have created reports and if I give them to someone else, they have to go to the printer setup to adjust them for their computer as well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top