Kamis, 26 Januari 2012

RE: [MS_AccessPros] Re: Combo Box used for parameter query, form, and report

 

Katrina

The key word DISTINCT goes right after the word SELECT as in:

SELECT DISTINCT CustName

FROM MyTable

But keep in mind if you have more than one field in the SELECT clause all of
those fields are taken into consideration.

Let's say you have 3 customers named Joe in different states.

If you wrote:

SELECT DISTINCT CustName

FROM MyTable

WHERE CustName = 'Joe'

It would return only one record. However if you wrote:

SELECT DISTINCT CustName, State

FROM MyTable

WHERE CustName = 'Joe'

It would return all 3: Joe from California, Joe from Washington (a less cool
state) and Joe from Arizona (an even less cool state). You get 3 records because
it's the combination of both fields that make a record distinct in this case.

To use DISTINCT in the query designer open the query and switch to SQL view.
Then just type in the DISTINCT as I have shown above.

Regards,
Bill Mosca,
Founder, MS_Access_Professionals
That'll do IT <http://thatlldoit.com/> http://thatlldoit.com
MS Access MVP
<https://mvp.support.microsoft.com/profile/Bill.Mosca>
https://mvp.support.microsoft.com/profile/Bill.Mosca

From: MS_Access_Professionals@yahoogroups.com
[mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of ka0t1c_ang3l
Sent: Thursday, January 26, 2012 2:22 PM
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] Re: Combo Box used for parameter query, form, and
report

I've done some research online and have found that if I set the query to a
DISTINCT query it will remove the duplicates. However, I'm not very Access savy
and don't know where exactly this should go.

Any help is appreciated!

Thanks!

Katrina

--- In MS_Access_Professionals@yahoogroups.com
<mailto:MS_Access_Professionals%40yahoogroups.com> , ka0t1c_ang3l <no_reply@...>
wrote:
>
> Crystal,
>
> Np! I'm more than happy to share with everyone else. I did run into a problem
that I can't seem to figure out how to do, or I've just been working on this
database TOO long. I've entered my invoice information and some invoices have
the same project #. Therefore, when I'm trying to run a report based on query
that groups all the project #'s together, in the drop down menu the same project
#'s are displayed multiple times because there's that many invoices with the
same project number. How can I keep duplicates from being displayed in the drop
down menu and have it displayed only once, yet would not delete out any records?
>
> I hope that makes sense!
>
> Thanks!
>
> Katrina
>
> --- In MS_Access_Professionals@yahoogroups.com
<mailto:MS_Access_Professionals%40yahoogroups.com> , Crystal <strive4peace2008@>
wrote:
> >
> > Hi Katrina,
> >
> > thanks for posting your solution :) glad you got it
> >
> >
> > Warm Regards,
> > Crystal
> >
> > Microsoft MVP
> > remote programming and training
> >
> > Access Basics by Crystal
> > http://www.AccessMVP.com/strive4peace
> > Free 100-page book that covers essentials in Access
> >
> > *
> > (: have an awesome day :)
> > *
> >
> >
> >
> >
> > ________________________________
> > From: ka0t1c_ang3l
> >
> > I found my error! I forgot to add in the code for the function.
> >
> > Option Compare Database
> > Option Explicit
> > Public bInReportOpenEvent As Boolean ' Is report in the Open event?
> >
> > Function IsLoaded(ByVal strFormName As String) As Boolean
> > ' Returns True if the specified form is open in Form view or Datasheet view.
> > Dim oAccessObject As AccessObject
> >
> > Set oAccessObject = CurrentProject.AllForms(strFormName)
> > If oAccessObject.IsLoaded Then
> > If oAccessObject.CurrentView <> acCurViewDesign Then
> > IsLoaded = True
> > End If
> > End If
> >
> > End Function
> >
> > Thanks!
> >
> > Katrina
> >
> >
> > --- In MS_Access_Professionals@yahoogroups.com
<mailto:MS_Access_Professionals%40yahoogroups.com> , ka0t1c_ang3l <no_reply@>
wrote:
> > >
> > > I created a custom dialog box (Vendor Dialog Box) that has a combo box and
I have a query that will be the recordsource of this combo box. I've also
created a report based on this query. What I want is when the report is opened
it will open the Vendor Dialog Box and allow the user to select a vendor from
the drop down menu, and based on that selection the report will be displayed. I
have added my capital project invoice log into the AssistantNeeded folder.
> > >
> > > I'm receiving a compile error: sub or function not defined. The following
is the code I'm using and I'm getting the error on the IsLoaded portion of the
code:
> > >
> > > Option Compare Database
> > >
> > > Private Sub Report_Close()
> > > DoCmd.Close acForm, "Vendor Dialog Box"
> > > End Sub
> > >
> > > Private Sub Report_Open(Cancel As Integer)
> > > ' Set public variable to true to indicate that the report
> > > ' is in the Open event
> > > bInReportOpenEvent = True
> > >
> > > ' Open Vendor Dialog Box
> > > DoCmd.OpenForm "Vendor Dialog Box", , , , , acDialog
> > >
> > > ' Cancel Report if User Clicked the Cancel Button
> > > If IsLoaded("Vendor Dialog Box") = False Then Cancel = True
> > >
> > > ' Set public variable to false to indicate that the
> > > ' Open event is completed
> > > bInReportOpenEvent = False
> > > End Sub
> > >
> > > Any help is appreciated!!
> > >
> > > Thanks!
> > >
> > > Katrina
> > >
> >
> >
> >
> >
> > ------------------------------------
> >
> > Yahoo! Groups Links
> >
> >
> >
> > [Non-text portions of this message have been removed]
> >
>

[Non-text portions of this message have been removed]

__._,_.___
.

__,_._,___

Tidak ada komentar:

Posting Komentar