Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 245
  • Last Modified:

DBCombo: Set source to select distinct??

I'm currently working with a DBCombo box [DBCombo1] that pulls data from a column called [Team_Affiliation].  Unfortunately there are several hundred records so what I'd like to do is only select distinct records to show in this combo box.  Right now I am setting the properties for [DBCombo1] at design time through the properties window.  It references a data connector [data1] which is connected to my database named[Emp_Data], table name [Complete_Emp].

If it is possible to connect the data to a DBCombo through a data environment that would be ideal, but I can also do it through a standard ADO connection string which is also set up.

Your help is appreciated!
0
TinLemon
Asked:
TinLemon
  • 4
  • 2
  • 2
  • +1
1 Solution
 
ayufansCommented:
So you're asking about the query to extract distinct data from your table ? am I reading this right ? or are you asking about something else ?
0
 
TinLemonAuthor Commented:
No... I fully understand how to pull distinct data using a query.  I'm trying to direct the source of a DBCombo to pull distinct data from a field in a table instead of pulling hundreds of records like it normally does.
0
 
JFercanCommented:
How about setting the source to a Command in the connection of the DataEnvironment that return the result ot the query?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
TinLemonAuthor Commented:
The query does not exist yet, so I try to write the source of the DBCombo as an SQL statement that "select distinct [team_affiliation] from [complete_emp]".  It's important to note that [complete_emp] is an existing query in my Access DB.

So in short, I am trying to set the source of my DBCombo to select distinct from a field in an existing query.

0
 
JFercanCommented:
The command object in the DE can be created with a sql statment, therefore you can create the result from your current query only it will run from the command object.

Why do a query in a query for one field?

Whouldn't it be easier to just query the table the [complete_emp] query looks at to get that field?

Just a thought!!!!!
0
 
TinLemonAuthor Commented:
Mods... I never found a sufficient answer and went with a completely UNRELATED solution.  How do I handle this?
0
 
SpideyModCommented:
TinLemon,
If you will post your solution here (unless it is against the membership agreement), then I can refund your points.

Experts, a refund request has been made.  You have 72 hours to object.  As long as TinLemon provides the answer, I intend to honor the request.

SpideyMod
Community Support Moderator @Experts Exchange
0
 
TinLemonAuthor Commented:
My solution was to use a regular combo box, and then just add each item to it one-by-one by using a loop.

With DataEnv
        With .rsTable1
             .Open
        For a = 1 To DataEnv.rsTable1.RecordCount
            If IsNull(![Field1]) Then
                a = a
            Else
                Combo1.AddItem (![Field1])
            End If
            .MoveNext
        Next a
End With

Thanks.
0
 
SpideyModCommented:
PAQ'd and all 20 points refunded.

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 4
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now