Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: Trying to get fancy

Geek News

Trying to get fancy
JimS 12/19/2008 9:06:01 PM
So, my users are asking to run their reports, integrity check query displays,
etc. by selection criteria. Say, for example, they want to run an integrity
check query that selects 1 or more "ProjectStatus" values. I've been
interposing a form that presents the project status choices in a list box and
lets them choose. Then I execute the form or report out of that form.

But query displays are different. And I'm tired of reinventing the wheel. I
want to have a generic "choose Project Status" routine that returns a string
-- "(3,5,7,8)" for project statuses 3, 5, 7 and 8. I can then use the "IN"
operator to code the where clause in my SQL statement or domain aggregate
call.

I can't get by the notion that a function isn't a form, so can't present a
list box control and return the selections. I could have the function "call"
the form, but how to return the results to the function? What's your
solution?
--
Jim
RE: Trying to get fancy
Clifford Bass 12/20/2008 12:31:04 AM
Hi Jim,

I think the easiest way to deal with that is when the user clicks the
button on the form for the report to create the in clause and pass it as
criteria when opening the report.

Dim strCriteria As String

' Code to construct the in clause

DoCmd.OpenReport "rptMyReport", acViewPreview, , strCriteria

Clifford Bass

"JimS" wrote:

[Quoted Text]
> So, my users are asking to run their reports, integrity check query displays,
> etc. by selection criteria. Say, for example, they want to run an integrity
> check query that selects 1 or more "ProjectStatus" values. I've been
> interposing a form that presents the project status choices in a list box and
> lets them choose. Then I execute the form or report out of that form.
>
> But query displays are different. And I'm tired of reinventing the wheel. I
> want to have a generic "choose Project Status" routine that returns a string
> -- "(3,5,7,8)" for project statuses 3, 5, 7 and 8. I can then use the "IN"
> operator to code the where clause in my SQL statement or domain aggregate
> call.
>
> I can't get by the notion that a function isn't a form, so can't present a
> list box control and return the selections. I could have the function "call"
> the form, but how to return the results to the function? What's your
> solution?
> --
> Jim
Re: Trying to get fancy
"Mike Painter" <mddotpainter[ at ]sbcglobal.net> 12/20/2008 3:14:46 AM
I have always added a Boolean field to such tables and used a fake listbox
in the form of a continuos form
I maintain the "state" between reports and have a "Select All" and "Clear
All" button under the box.
One nice thing is that they can come back and run it again without having to
go through the selection process again.

They check what they want to see and run the report from the form.
It can work well for two or more choices as in "I want to see tests A,B,C
done by doctors Smith, Jones and Death between this date and that date."

No code to write and you just add a Field = True to teh query.

JimS wrote:
[Quoted Text]
> So, my users are asking to run their reports, integrity check query
> displays, etc. by selection criteria. Say, for example, they want to
> run an integrity check query that selects 1 or more "ProjectStatus"
> values. I've been interposing a form that presents the project status
> choices in a list box and lets them choose. Then I execute the form
> or report out of that form.
>
> But query displays are different. And I'm tired of reinventing the
> wheel. I want to have a generic "choose Project Status" routine that
> returns a string -- "(3,5,7,8)" for project statuses 3, 5, 7 and 8. I
> can then use the "IN" operator to code the where clause in my SQL
> statement or domain aggregate call.
>
> I can't get by the notion that a function isn't a form, so can't
> present a list box control and return the selections. I could have
> the function "call" the form, but how to return the results to the
> function? What's your solution?


Re: Trying to get fancy
"Stuart McCall" <smccall[ at ]myunrealbox.com> 12/20/2008 4:59:41 AM
"JimS" <JimS[ at ]discussions.microsoft.com> wrote in message
news:C4EDDD43-2651-4857-9CE1-E74A61E5A26D[ at ]microsoft.com...
[Quoted Text]
> So, my users are asking to run their reports, integrity check query
> displays,
> etc. by selection criteria. Say, for example, they want to run an
> integrity
> check query that selects 1 or more "ProjectStatus" values. I've been
> interposing a form that presents the project status choices in a list box
> and
> lets them choose. Then I execute the form or report out of that form.
>
> But query displays are different. And I'm tired of reinventing the wheel.
> I
> want to have a generic "choose Project Status" routine that returns a
> string
> -- "(3,5,7,8)" for project statuses 3, 5, 7 and 8. I can then use the "IN"
> operator to code the where clause in my SQL statement or domain aggregate
> call.
>
> I can't get by the notion that a function isn't a form, so can't present a
> list box control and return the selections. I could have the function
> "call"
> the form, but how to return the results to the function? What's your
> solution?
> --
> Jim

You could use code similar to below in your function:

Dim rtn As String
Dim item As Variant

With Forms!ProjectStatus!ListboxName
For Each item In .ItemsSelected
rtn = rtn & "," & item
Next
rtn = Mid(rtn,2) 'Strip off 1st comma
End With
rtn = "(" & rtn & ")"

(Untested air code)


Re: Trying to get fancy
Clifford Bass 12/20/2008 8:50:00 PM
Hi Mike,

Nice idea, I may adapt it for some circumstances. Question: Do your
users run into issues when more than one user it trying to run the same
report at the same time?

Clifford Bass

"Mike Painter" wrote:

[Quoted Text]
> I have always added a Boolean field to such tables and used a fake listbox
> in the form of a continuos form
> I maintain the "state" between reports and have a "Select All" and "Clear
> All" button under the box.
> One nice thing is that they can come back and run it again without having to
> go through the selection process again.
>
> They check what they want to see and run the report from the form.
> It can work well for two or more choices as in "I want to see tests A,B,C
> done by doctors Smith, Jones and Death between this date and that date."
>
> No code to write and you just add a Field = True to the query.
Re: Trying to get fancy
John W. Vinson <jvinson[ at ]STOP_SPAM.WysardOfInfo.com> 12/20/2008 9:02:36 PM
On Sat, 20 Dec 2008 12:50:00 -0800, Clifford Bass
<CliffordBass[ at ]discussions.microsoft.com> wrote:

[Quoted Text]
>Hi Mike,
>
> Nice idea, I may adapt it for some circumstances. Question: Do your
>users run into issues when more than one user it trying to run the same
>report at the same time?

One way to get around that is to have a local table in the frontend of your
split application, related one-to-one to the table for reporting; you would
use a form based on an outer join, thereby creating a "report me" record only
when needed.
--

John W. Vinson [MVP]
Re: Trying to get fancy
Clifford Bass 12/20/2008 10:23:00 PM
Hi John,

That sounds better to me! The idea of modifying records within the
database everytime you wanted to do a report did not seem like the best way
to go. It could cause troubles for someone who is trying to modify actual
data. Or troubles related to date/time records were last modified.

Thanks,

Clifford Bass

"John W. Vinson" wrote:

[Quoted Text]
> On Sat, 20 Dec 2008 12:50:00 -0800, Clifford Bass
> <CliffordBass[ at ]discussions.microsoft.com> wrote:
>
> >Hi Mike,
> >
> > Nice idea, I may adapt it for some circumstances. Question: Do your
> >users run into issues when more than one user it trying to run the same
> >report at the same time?
>
> One way to get around that is to have a local table in the frontend of your
> split application, related one-to-one to the table for reporting; you would
> use a form based on an outer join, thereby creating a "report me" record only
> when needed.
> --
>
> John W. Vinson [MVP]
Re: Trying to get fancy
Marshall Barton <marshbarton[ at ]wowway.com> 12/21/2008 3:08:12 PM
Clifford Bass wrote:
[Quoted Text]
> Nice idea, I may adapt it for some circumstances. Question: Do your
>users run into issues when more than one user it trying to run the same
>report at the same time?


Another way is to use a collection. See Multi Select
Example at
http://www.members.shaw.ca/AlbertKallal/msaccess/msaccess.html

--
Marsh
MVP [MS Access]
Re: Trying to get fancy
Clifford Bass 12/21/2008 8:15:03 PM
Hi Marshall,

I think I like that one also. Thanks for pointing it out!

Clifford Bass

"Marshall Barton" wrote:

[Quoted Text]
> Clifford Bass wrote:
> > Nice idea, I may adapt it for some circumstances. Question: Do your
> >users run into issues when more than one user it trying to run the same
> >report at the same time?
>
>
> Another way is to use a collection. See Multi Select
> Example at
> http://www.members.shaw.ca/AlbertKallal/msaccess/msaccess.html
>
> --
> Marsh
> MVP [MS Access]

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net