Welcome to the { mindfrost82.com } forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

Go Back   { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Microsoft > MS Office > Access

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-15-2008, 02:40 PM
=?Utf-8?B?R29sZmlucmF5?=
 
Posts: n/a
What the boss wants now?

The boss wants to be able to sort a report before he prints it. It needs to
sort by either Area, School District, Plan Type, or Project Approval. Is
there a way to put a combo or something to allow him to pick his sort? Thanks
a bunch!!!
Reply With Quote
  #2 (permalink)  
Old 08-15-2008, 03:05 PM
Tom van Stiphout
 
Posts: n/a
Re: What the boss wants now?

On Fri, 15 Aug 2008 06:40:00 -0700, Golfinray
<Golfinray@discussions.microsoft.com> wrote:

Yes. When you click the report button, pop up a form with that
dropdown. Then your report in its Report_Open event can "look back" at
that form and decide how to set the sort order. You know the sort
order should be set in the report, not in the underlying query, right?

-Tom.
Microsoft Access MVP


>The boss wants to be able to sort a report before he prints it. It needs to
>sort by either Area, School District, Plan Type, or Project Approval. Is
>there a way to put a combo or something to allow him to pick his sort? Thanks
>a bunch!!!

Reply With Quote
  #3 (permalink)  
Old 08-15-2008, 03:15 PM
strive4peace
 
Posts: n/a
Re: What the boss wants now?

I find that the easiest way to sort/group by different ways on a report
is to base the report on a query

ie:

SELECT [fieldname1] as [Sort1]
, [fieldname2] as [Sort2]
, [fieldname3]
, [fieldname3]
FROM [tablename]
etc

~~~

use a form to collect the report critera and the sort method. Then, on
the button to process the report, replace the query it is based on
before you open it

'~~~~~~~~~~~~~~~~~~~~~ MakeQuery
Sub MakeQuery( _
ByVal pSql As String, _
ByVal qName As String)

'modified 3-30-08
'crystal
'strive4peace2008 at yahoo dot com

On Error GoTo Proc_Err

debug.print pSql

'if query already exists, update the SQL
'if not, create the query

If Nz(DLookup("[Name]", "MSysObjects", _
"[Name]='" & qName _
& "' And [Type]=5"), "") = "" Then
CurrentDb.CreateQueryDef qName, pSql
Else
'if query is open, close it
on error resume next
DoCmd.Close acQuery, qName, acSaveNo
On Error GoTo Proc_Err
CurrentDb.QueryDefs(qName).sql = pSql
End If

Proc_exit:
CurrentDb.QueryDefs.Refresh
DoEvents
Exit Sub

Proc_error:
MsgBox Err.Description, , _
"ERROR " & Err.Number & " MakeQuery"

Resume Proc_Exit

'if you want to single-step code to find error, CTRL-Break at MsgBox
'then set this to be the next statement
Resume
End Sub
'~~~~~~~~~~~~~~~~~~~~~~~~~~

to use the MakeQuery procedure, put this in your code:

MakeQuery strSQL, "YourQueryName"


Warm Regards,
Crystal

remote programming and training

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace

*
(: have an awesome day :)
*




Golfinray wrote:
> The boss wants to be able to sort a report before he prints it. It needs to
> sort by either Area, School District, Plan Type, or Project Approval. Is
> there a way to put a combo or something to allow him to pick his sort? Thanks
> a bunch!!!

Reply With Quote
  #4 (permalink)  
Old 08-15-2008, 03:28 PM
=?Utf-8?B?R29sZmlucmF5?=
 
Posts: n/a
Re: What the boss wants now?

Tom. I can put a combo on the form with the sort selection, but how do I get
that to work in the report. I don't really want to make that selection in the
query for other reasons. Thanks!

"Tom van Stiphout" wrote:

> On Fri, 15 Aug 2008 06:40:00 -0700, Golfinray
> <Golfinray@discussions.microsoft.com> wrote:
>
> Yes. When you click the report button, pop up a form with that
> dropdown. Then your report in its Report_Open event can "look back" at
> that form and decide how to set the sort order. You know the sort
> order should be set in the report, not in the underlying query, right?
>
> -Tom.
> Microsoft Access MVP
>
>
> >The boss wants to be able to sort a report before he prints it. It needs to
> >sort by either Area, School District, Plan Type, or Project Approval. Is
> >there a way to put a combo or something to allow him to pick his sort? Thanks
> >a bunch!!!

>

Reply With Quote
  #5 (permalink)  
Old 08-15-2008, 03:29 PM
strive4peace
 
Posts: n/a
Re: What the boss wants now?

ps

the [Sort1] and [Sort2] fields will be set as the sort/group by fields
in the report definition

Warm Regards,
Crystal

remote programming and training

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace

*
(: have an awesome day :)
*




Tom van Stiphout wrote:
> On Fri, 15 Aug 2008 06:40:00 -0700, Golfinray
> <Golfinray@discussions.microsoft.com> wrote:
>
> Yes. When you click the report button, pop up a form with that
> dropdown. Then your report in its Report_Open event can "look back" at
> that form and decide how to set the sort order. You know the sort
> order should be set in the report, not in the underlying query, right?
>
> -Tom.
> Microsoft Access MVP
>
>
>> The boss wants to be able to sort a report before he prints it. It needs to
>> sort by either Area, School District, Plan Type, or Project Approval. Is
>> there a way to put a combo or something to allow him to pick his sort? Thanks
>> a bunch!!!

Reply With Quote
  #6 (permalink)  
Old 08-15-2008, 03:33 PM
strive4peace
 
Posts: n/a
Re: What the boss wants now?

ps

the [Sort1] and [Sort2] fields will be set as the sort/group by fields
in the report definition

the only time a sort order in an underlying query is actually used by
the report is if the report has no sorting or grouping defined

Warm Regards,
Crystal

remote programming and training

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace

*
(: have an awesome day :)
*




strive4peace wrote:
> I find that the easiest way to sort/group by different ways on a report
> is to base the report on a query
>
> ie:
>
> SELECT [fieldname1] as [Sort1]
> , [fieldname2] as [Sort2]
> , [fieldname3]
> , [fieldname3]
> FROM [tablename]
> etc
>
> ~~~
>
> use a form to collect the report critera and the sort method. Then, on
> the button to process the report, replace the query it is based on
> before you open it
>
> '~~~~~~~~~~~~~~~~~~~~~ MakeQuery
> Sub MakeQuery( _
> ByVal pSql As String, _
> ByVal qName As String)
>
> 'modified 3-30-08
> 'crystal
> 'strive4peace2008 at yahoo dot com
>
> On Error GoTo Proc_Err
>
> debug.print pSql
>
> 'if query already exists, update the SQL
> 'if not, create the query
>
> If Nz(DLookup("[Name]", "MSysObjects", _
> "[Name]='" & qName _
> & "' And [Type]=5"), "") = "" Then
> CurrentDb.CreateQueryDef qName, pSql
> Else
> 'if query is open, close it
> on error resume next
> DoCmd.Close acQuery, qName, acSaveNo
> On Error GoTo Proc_Err
> CurrentDb.QueryDefs(qName).sql = pSql
> End If
>
> Proc_exit:
> CurrentDb.QueryDefs.Refresh
> DoEvents
> Exit Sub
>
> Proc_error:
> MsgBox Err.Description, , _
> "ERROR " & Err.Number & " MakeQuery"
>
> Resume Proc_Exit
>
> 'if you want to single-step code to find error, CTRL-Break at MsgBox
> 'then set this to be the next statement
> Resume
> End Sub
> '~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> to use the MakeQuery procedure, put this in your code:
>
> MakeQuery strSQL, "YourQueryName"
>
>
> Warm Regards,
> Crystal
>
> remote programming and training
>
> Access Basics
> 8-part free tutorial that covers essentials in Access
> http://www.AccessMVP.com/strive4peace
>
> *
> (: have an awesome day :)
> *
>
>
>
>
> Golfinray wrote:
>> The boss wants to be able to sort a report before he prints it. It
>> needs to sort by either Area, School District, Plan Type, or Project
>> Approval. Is there a way to put a combo or something to allow him to
>> pick his sort? Thanks a bunch!!!

Reply With Quote
  #7 (permalink)  
Old 08-15-2008, 10:54 PM
=?Utf-8?B?S2VuIFNoZXJpZGFu?=
 
Posts: n/a
RE: What the boss wants now?

Reports have an OrderBy and OrderByOn property so if the report is otherwise
ungrouped/unsorted you can set these in the report's Open event procedure by
referencing the combo box on your dialogue form:

Const FORMNOTOPEN = 2450
Dim frm As Form
Dim ctrl As Control

On Error Resume Next
Set frm = Forms("YourForm")
Select Case Err.Number
Case 0
' no error
Set ctrl = frm("YourComboBox")
' if a sort order has been selected
' then order the report
If Not IsNull(ctrl) Then
Me.OrderBy = ctrl
Me.OrderByOn = True
End If
Case FORMNOTOPEN
' open report unordered
Case Else
' unknown error so inform user
MsgBox Err.Description, vbExclamation, "Error"
End Select

Select the sort order you want in the combo box on the dialogue form and
open the report from a button on the form with:

DoCmd.OpenReport "YourReport"

Ken Sheridan
Stafford, England

"Golfinray" wrote:

> The boss wants to be able to sort a report before he prints it. It needs to
> sort by either Area, School District, Plan Type, or Project Approval. Is
> there a way to put a combo or something to allow him to pick his sort? Thanks
> a bunch!!!


Reply With Quote
Reply

  { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Microsoft > MS Office > Access


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 04:33 PM.


Powered by vBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
© 1999-2008 mindfrost82.com v11.0


Sponsors:
Electricity Suppliers | Turbo Tax software | MPAA | Mobile Phone | Credit Counseling



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114