Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    San Francisco, CA, USA
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unique Values (2002)

    I have a combo box that is populated by a query shows CompanyNames with many duplicates. I only want one instance of the company name in the combo box. I tried Distinctrow to no avail.
    Frank Hoeffer

  2. #2
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Unique Values (2002)

    Try, as the start of the SQL statement

    SELECT DISTINCT

    Not DistinctRow
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

  3. #3
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    San Francisco, CA, USA
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Unique Values (2002)

    Still not limiting CompanyName to a unique name.
    The SQL Code I'm using is:
    SELECT DISTINCT [tblVendors-Accounts].AccountNumber, [tblVendors-Accounts].Account, tblVendors.CompanyName, tblVendors.ContactName
    FROM [tblVendors-Accounts] INNER JOIN tblVendors ON [tblVendors-Accounts].AccountNumber = tblVendors.AccountNumber
    WHERE ((([tblVendors-Accounts].AccountNumber)=[cboAccountNumber]));
    Frank

  4. #4
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Unique Values (2002)

    It won't give you just distinct Company names but it will give a distinct of all the fields you have chosen.

    Your statement

    SELECT DISTINCT [tblVendors-Accounts].AccountNumber, [tblVendors-Accounts].Account, tblVendors.CompanyName, tblVendors.ContactName
    FROM [tblVendors-Accounts] INNER JOIN tblVendors ON [tblVendors-Accounts].AccountNumber = tblVendors.AccountNumber
    WHERE ((([tblVendors-Accounts].AccountNumber)=[cboAccountNumber]));

    would need to be changed to

    SELECT DISTINCT tblVendors.CompanyName
    FROM [tblVendors-Accounts] INNER JOIN tblVendors ON [tblVendors-Accounts].AccountNumber = tblVendors.AccountNumber
    WHERE ((([tblVendors-Accounts].AccountNumber)=[cboAccountNumber]));

    This should give you distinct Company names.
    HTH
    Pat <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  5. #5
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    San Francisco, CA, USA
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    That did It!

    Thanks! <img src=/S/bouncenburn.gif border=0 alt=bouncenburn width=31 height=31>
    Frank

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •