How to select & display distinct values

Hello,

I need help with a form please.

My form has two controls, the first being a combo box.  This box should 
select the company name from a lookup table.  The lookup table has only two 
companies in it, however, they each are repeated several time.  Company 1 has 
about 10 rows, company 2 has 3 rows.  I used the query builder and came up 
with the statement:

 "SELECT DISTINCT Lktbl_Role_Master.CompanyName
FROM Lktbl_Role_Master;"

When I run the statement directly from query view, it executes perfectly and 
returns exactly two rows (one for each company, in a datasheet view) however, 
when I put the Select statement into the rowsource property for the control, 
the combobox does not populate and nothing is displayed on the form.  

Table Definition:
ID    Autonumber   primary key
Company Name     text
Role Name            text

Can anyone help me understand what I am doing wrong?

TIA,
Rich
0
Utf
7/30/2007 7:48:01 PM
access.formscoding 7494 articles. 0 followers. Follow

5 Replies
1122 Views

Similar Articles

[PageSpeed] 42

=?Utf-8?B?cmljaA==?= <rich@discussions.microsoft.com> wrote in
news:89158CDB-C277-4DC9-84B2-EE6EAA880B19@microsoft.com: 

> Hello,
> 
> I need help with a form please.
> 
> My form has two controls, the first being a combo box.  This
> box should select the company name from a lookup table.  The
> lookup table has only two companies in it, however, they each
> are repeated several time.  Company 1 has about 10 rows,
> company 2 has 3 rows.  I used the query builder and came up 
> with the statement:
> 
>  "SELECT DISTINCT Lktbl_Role_Master.CompanyName
> FROM Lktbl_Role_Master;"
> 
> When I run the statement directly from query view, it executes
> perfectly and returns exactly two rows (one for each company,
> in a datasheet view) however, when I put the Select statement
> into the rowsource property for the control, the combobox does
> not populate and nothing is displayed on the form.  
> 
> Table Definition:
> ID    Autonumber   primary key
> Company Name     text
> Role Name            text
> 
> Can anyone help me understand what I am doing wrong?
> 
> TIA,
> Rich

Check the column count and column widths property  of the 
combobox, it may be set to hide the first column,

-- 
Bob Quintal

PA is y I've altered my email address.

-- 
Posted via a free Usenet account from http://www.teranews.com

0
Bob
7/30/2007 8:04:21 PM
On Jul 30, 2:48 pm, rich <r...@discussions.microsoft.com> wrote:
> Hello,
>
> I need help with a form please.
>
> My form has two controls, the first being a combo box.  This box should
> select the company name from a lookup table.  The lookup table has only two
> companies in it, however, they each are repeated several time.  Company 1 has
> about 10 rows, company 2 has 3 rows.  I used the query builder and came up
> with the statement:
>
>  "SELECT DISTINCT Lktbl_Role_Master.CompanyName
> FROM Lktbl_Role_Master;"
>
> When I run the statement directly from query view, it executes perfectly and
> returns exactly two rows (one for each company, in a datasheet view) however,
> when I put the Select statement into the rowsource property for the control,
> the combobox does not populate and nothing is displayed on the form.  
>
> Table Definition:
> ID    Autonumber   primary key
> Company Name     text
> Role Name            text
>
> Can anyone help me understand what I am doing wrong?
>
> TIA,
> Rich

I don't see a problem.  Does it work (sort of) without the "Distinct"?

0
OldPro
7/30/2007 8:52:07 PM
Hello,

Not sure what I did to resolve this, but now it's working.

I kept re-creating the form using the form wizard and setting the 
properties.  Right now, the cbo properties are:
Row Source Type:  Table/Query
Row Source:  SELECT DISTINCT Lktbl_Role_Master.CompanyName FROM 
Lktbl_Role_Master; 
Bound Column: 1   (Table has total of 3 columns, with 1st being ID, which is 
autonumber for the PK)
Column count: 1

Dorian,
I believe I understand why you say the table needs a re-design.  I think I'm 
violating 1st normal form.  

1NF:  Eliminate duplicative columns from the same table. 
Create separate tables for each group of related data and identify each row 
with a unique column or set of columns (the primary key). 
http://http://databases.about.com/od/specificproducts/a/normalization.htm

This, I think would lead to a new table (lktbl_Company) (which I do have).  
This table would look something like:
CompanyID   Autonumber  (this becomes the PK)
CompanyName   Text

This table would then have 1 row for each unique company.
CompanyName would be a FK pointing to Lktbl_Role_Master.CompanyName.    Am I 
on the right trail with my thinking?  I had it like this previously but 
deleted the relationships because I have another form with the same problem 
and I thought I may have some kind of vicious cirle of relationships because 
it would not work.  

Anyway, this problem looks resolved but can either of you recommend a good 
online article that gives medium to advanced level discussion of using a 
combo box?  I still have got to get the issue resolved with the other (more 
controls on it) form.

Thanks very much!!

Rich



"OldPro" wrote:

> On Jul 30, 2:48 pm, rich <r...@discussions.microsoft.com> wrote:
> > Hello,
> >
> > I need help with a form please.
> >
> > My form has two controls, the first being a combo box.  This box should
> > select the company name from a lookup table.  The lookup table has only two
> > companies in it, however, they each are repeated several time.  Company 1 has
> > about 10 rows, company 2 has 3 rows.  I used the query builder and came up
> > with the statement:
> >
> >  "SELECT DISTINCT Lktbl_Role_Master.CompanyName
> > FROM Lktbl_Role_Master;"
> >
> > When I run the statement directly from query view, it executes perfectly and
> > returns exactly two rows (one for each company, in a datasheet view) however,
> > when I put the Select statement into the rowsource property for the control,
> > the combobox does not populate and nothing is displayed on the form.  
> >
> > Table Definition:
> > ID    Autonumber   primary key
> > Company Name     text
> > Role Name            text
> >
> > Can anyone help me understand what I am doing wrong?
> >
> > TIA,
> > Rich
> 
> I don't see a problem.  Does it work (sort of) without the "Distinct"?
> 
> 
0
Utf
7/30/2007 9:22:00 PM
You are on the right track with your revised table design.
For details about combo boxes, Access Help screens should have most 
everything you need to know.
Its difficult to recommend books because it depends on your expertise level 
and what Access version you have. Go to Amazon.com book section, type in 
Access and read the reviews.

Dorian

"rich" wrote:

> Hello,
> 
> Not sure what I did to resolve this, but now it's working.
> 
> I kept re-creating the form using the form wizard and setting the 
> properties.  Right now, the cbo properties are:
> Row Source Type:  Table/Query
> Row Source:  SELECT DISTINCT Lktbl_Role_Master.CompanyName FROM 
> Lktbl_Role_Master; 
> Bound Column: 1   (Table has total of 3 columns, with 1st being ID, which is 
> autonumber for the PK)
> Column count: 1
> 
> Dorian,
> I believe I understand why you say the table needs a re-design.  I think I'm 
> violating 1st normal form.  
> 
> 1NF:  Eliminate duplicative columns from the same table. 
> Create separate tables for each group of related data and identify each row 
> with a unique column or set of columns (the primary key). 
> http://http://databases.about.com/od/specificproducts/a/normalization.htm
> 
> This, I think would lead to a new table (lktbl_Company) (which I do have).  
> This table would look something like:
> CompanyID   Autonumber  (this becomes the PK)
> CompanyName   Text
> 
> This table would then have 1 row for each unique company.
> CompanyName would be a FK pointing to Lktbl_Role_Master.CompanyName.    Am I 
> on the right trail with my thinking?  I had it like this previously but 
> deleted the relationships because I have another form with the same problem 
> and I thought I may have some kind of vicious cirle of relationships because 
> it would not work.  
> 
> Anyway, this problem looks resolved but can either of you recommend a good 
> online article that gives medium to advanced level discussion of using a 
> combo box?  I still have got to get the issue resolved with the other (more 
> controls on it) form.
> 
> Thanks very much!!
> 
> Rich
> 
> 
> 
> "OldPro" wrote:
> 
> > On Jul 30, 2:48 pm, rich <r...@discussions.microsoft.com> wrote:
> > > Hello,
> > >
> > > I need help with a form please.
> > >
> > > My form has two controls, the first being a combo box.  This box should
> > > select the company name from a lookup table.  The lookup table has only two
> > > companies in it, however, they each are repeated several time.  Company 1 has
> > > about 10 rows, company 2 has 3 rows.  I used the query builder and came up
> > > with the statement:
> > >
> > >  "SELECT DISTINCT Lktbl_Role_Master.CompanyName
> > > FROM Lktbl_Role_Master;"
> > >
> > > When I run the statement directly from query view, it executes perfectly and
> > > returns exactly two rows (one for each company, in a datasheet view) however,
> > > when I put the Select statement into the rowsource property for the control,
> > > the combobox does not populate and nothing is displayed on the form.  
> > >
> > > Table Definition:
> > > ID    Autonumber   primary key
> > > Company Name     text
> > > Role Name            text
> > >
> > > Can anyone help me understand what I am doing wrong?
> > >
> > > TIA,
> > > Rich
> > 
> > I don't see a problem.  Does it work (sort of) without the "Distinct"?
> > 
> > 
0
Utf
7/30/2007 10:30:03 PM
On Mon, 30 Jul 2007 14:22:00 -0700, rich <rich@discussions.microsoft.com>
wrote:

>This, I think would lead to a new table (lktbl_Company) (which I do have).  
>This table would look something like:
>CompanyID   Autonumber  (this becomes the PK)
>CompanyName   Text
>
>This table would then have 1 row for each unique company.
>CompanyName would be a FK pointing to Lktbl_Role_Master.CompanyName.    Am I 
>on the right trail with my thinking?  

Not quite.

CompanyID would be the foreign key, pointing to Lktbl_Role_Master.CompanyID.
The Role Master table would not contain a company name field *at all*, just
the ID.

>I had it like this previously but 
>deleted the relationships because I have another form with the same problem 
>and I thought I may have some kind of vicious cirle of relationships because 
>it would not work.  
>
>Anyway, this problem looks resolved but can either of you recommend a good 
>online article that gives medium to advanced level discussion of using a 
>combo box?  I still have got to get the issue resolved with the other (more 
>controls on it) form.

Check out the references in:

Jeff Conrad's resources page:
http://www.accessmvp.com/JConrad/accessjunkie/resources.html

The Access Web resources page:
http://www.mvps.org/access/resources/index.html

A free tutorial written by Crystal (MS Access MVP):
http://allenbrowne.com/casu-22.html

MVP Allen Browne's tutorials:
http://allenbrowne.com/links.html#Tutorials

             John W. Vinson [MVP]
0
John
7/30/2007 10:51:03 PM
Reply:

Similar Artilces:

Combo box list selection based on earlier selection by user
HI, I have a form that has a combo box 1 (Product) that reads a the Product table and has a unique id attached to each product (RO#). There is a second combo box 2 that is RO#. Now what I would like to do is when a user selects a Product in combo box 1, the system should lookup the Product selected from combo box 1 and upload the corresponding RO# in the combo box 2 list. Now I am using both combo boxes as Unbound and in the combo box 2 I have the two columns Product and RO# - in the Criteria row of RO# I have the following: Like IIf([Forms]![xa_f_lookup]![RO#]=" ",[Forms]![x...

Run report on multi selected records.
I try to make a report for a custom entity that works like the Account Summary: let's say that it's Customer's Inquiry Summary for entity Customer's Inquiry I made the report so that I'm able to run the report on Customer's Inquiry Form. But when I select multi records in the list of Customer's Inquiry and run report, only one record is show in one page of the the report. I would like to have the selected records appear in the report with each record on each page. How can I do this? ...

Displaying itmes in list that have a quanity next to them
I have a spread sheet with 2 tabs. I use the 1st tab to list items and prices.. i.e. Quanity Description Price 1 Telephone A 34.95 0 telephone B 43.95 5 Telephone C 32.43 7 Telephone D 54.98 0 Telephone E 43.44 Note I have about 60 of these On Sheet 2, I want to list in a Row by Row, the items that have a quanity next to them i.e. Quanity Description Price 1 Telephone A 34.95 5 Telephone C 32.43 7 ...

Can't select objects in Excel 2007
I'm trying to create a form in Excel 2007, and although I can manipulate, copy & paste controls (check boxes, etc) I can't select multiple objects to align them, etc. I've checked on-line help (and have followed the instructions), and other websites, but no one seems to have indicated a problem. It is extremely cumbersome and I need a solution. Any ideas? Thanks in advance, Jim Berglund I know this is about a year too late, but it may help others who have stumbled across this page looking for similar help. On the Home tab, in the Editing group, click Find & Select....

Lot Selection not Showing when I select PO on Receiving Entry
Usually, the Lot selection screen would pop up when I select a PO at the Line Detail of the Receivings Entry, now it does not! And GP will let items post without a lot number! It seems as if a setting has changed. Any ideas anyone? Any help is appreciated. Thanks, R Are you sure the item is marked to track lots? This wiould be set item by item on the Item Maintenance Options window. -- Richard L. Whaley Author / Consultant / MVP 2006-2008 Documentation for Software Users Get our Free Tips and Tricks Newsletter and check out our books at http://www.AccoladePublications.com &q...

problem with display of categories in Calendar
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel When I assign a category to a new event with a specific time (as opposed to an &quot;all day&quot; event), the only thing that changes is the color of the font. There is no &quot;box&quot; of color such as that shown in the video on &quot;how to add events to categories.&quot; I am viewing the calendar in the monthly mode. The &quot;all day&quot; events appear in a brightly colored box depending on the category. But the &quot;timed&quot; events (which are clearly the m...

Select contact then hangs
Hi, please help. I have a user that when she selects a contact using To: in a new email, after selecting 2, it closes outlook??. Spec is W2kSP4\office2k with all windows updates and office updates installed. Profile has been deleted and re-created, plus i have set up personal folders and moved contacts into there, and set that folder as a default, but makes no difference. Please help. ...

how do I create formula for if a value greater that zero is added it shades another cell?
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel how do I create formula for - if a value greater that zero is added in one cell it shades another cell? In article <59bb353d.-1@webcrossing.JaKIaxP2ac0>, tsunnyvale@officeformac.com wrote: > Version: 2008 > Operating System: Mac OS X 10.6 (Snow Leopard) > Processor: Intel > > how do I create formula for - if a value greater that zero is added in one > cell it shades another cell? Use Conditional Formatting in the cell you want shaded. Then you just need to set up a f...

Cell display in 2007
After revising a formula in Excel 2007, the new number is presented overlaid on top of the previous number in the cell. If I minimize EXCEL and then then maximize, the cell data presents correctly. Formula, Calculation Options is set to Automatic. The size of the spreadsheet/file does not matter. I've only had EXCEL 2007 a few weeks and my PC is new. Our IT shop has changed PC's virtual memory to 5120-8192 with no improvement. There have been reports of a bug in a windows update for office 2007 November 10th Can cause "visual leaking" from one sheet to an...

Detailed ASP.Net info not displaying in browser
Team, I am developing a web service. In testing in on my enw PC, I am expecting to see exceptions thrown appear on my browser. Instead I am getting an HTTP 500 Internal Server Error page and I am not seeing my exception details. The web.config file being used has the setting <customErrors mode="Off"/>. This should allow me to see the detailed exception info. On a different computer - same code - same web config - the exception details display. Not sure what else on my new computer needs set in order to see this info. Please advise. Much thanks, Tim Reynolds Tim R...

Selecting rows from various sheets
Hi all, I have several sheets with a few columns in each. One colum in each sheet has a unique value. Most of these unique values are th same in each sheet but not all. Is there any way that I can set up new sheet that will have the unique value in column 1 and th corresponding column values frommeach sheet beside it. For example Sheet 1 aa 1 1 1 bb 2 2 2 cc 3 3 3 Sheet 2 aa 4 4 cc 5 5 Result aa 1 1 1 4 4 bb 2 2 2 cc 3 3 3 5 5 Thanks alot, Sha -- sha ----------------------------------------------------------------------- shav's Profile: http...

null value pass from form into query
For some reason I can't seem to get this to work and was hoping posting here would speed up finding the resolution. I have a form that the users a specifying a value from based on a list box. The users press a button on the form after doing the selection and it executes a query with criteria based on the value from the field; the query is using [Forms]![frmBatchesNeedingIndexing]![Contract].[Value] as the critera. This works fine when a users specifies a value. The problem I'm experiencing is I need this list box to have the capability to have a null value passed to the que...

How do I change the elements displayed in the message list
How do I change the elements displayed in the message list. For example, to list "To" or "From" edit the view - to change just one folder, click on the row of field names and choose custom. To make all folders the same see http://www.outlook-tips.net/howto/grouping.htm -- Diane Poremsky [MVP - Outlook] Author, Teach Yourself Outlook 2003 in 24 Hours Coauthor, OneNote 2003 for Windows (Visual QuickStart Guide) Need Help with Common Tasks? http://www.outlook-tips.net/beginner/ Outlook 2007: http://www.slipstick.com/outlook/ol2007/ Outlook Tips: http://www.outlook-tips...

select text in Calendar
I'm working on a calendar in Publisher. I'm adding text into a cell by spacing down 1 point, then typing in 8 points. Doing fine until April. At that time, I can only select cells (whole days). It will not let me select the text. Help is no help. Any hints out there. Did I accidentally select something to do this? Bonnie Have you added a picture to the cell or a shape? If you have send it to the back, make the cell no fill and try again. -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "GoBonnieGo" <GoB...

macro to filter data based on selected data
Hi, I am looking for a macro that requests input of a reference code and then a date and then filters the data in my spreadsheet based on this criteria. I am using excel 2007. Any help with this will be greatly appreciated. You can probably record a macro while doing it manually and then clean it up and add input boxes to ask the question or input your variable in a cell and use that. If all else fails, If desired, send your file to my address below. I will only look if: 1. You send a copy of this message on an inserted sheet 2. You give me the newsgroup and the ...

Outlook displaying HTML weirdly and attachments as plain text?? Help.
Hi, All of a sudden my SBS 2003 box is passing me emails from people who are sending me email in HTML format but I see it like this: This is a multi-part message in MIME format. ------_=_NextPart_001_01C89B01.1EE51FF9 Content-Type: multipart/alternative; boundary="----_=_NextPart_002_01C89B01.1EE51FF9" ------_=_NextPart_002_01C89B01.1EE51FF9 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Attachments appear like this: ------_=_NextPart_001_01C89B01.1EE51FF9 Content-Type: application/vnd.ms-excel; name="ACCORD 2007-8....

Link select with a blast
I have Win 7 Home Premium, x64. Quite often, when I select a link, a mouse pointer changes to a palm with a blast. I understand, the palm is the standard mouse pointer for link select, but what is the blast? What it indicates? -- Ilya Zeldes Fort Myers, Florida Hi Ilya, I suspect that this is being caused by a tracking program. Run something like Ad-Aware and see if it indicates a tracking company. If so, you can delete it, however, it might prevent you from accessing that particular website. Dave "Ilya Zeldes" wrote in message news:7A6FF9B1-5512-44...

Select Case in a Change Event
Hi, I am trying to use a worksheet Change Event to trap changes to specific columns. depending on which column is chnaged by the user, the value in another ciolumn will be altered; so, changes in either column O or P will update column Q, changes in either column T or U will update column V and changes in column Z or AA will update column AB. What I can't figure out is the Select Case bit (where I've got the shouted question below). Here's what I've put together, any comments would be much appreciated. Private Sub Worksheet_Change(ByVal Target As Range) ...

Value Limits In A chart
Is there any way possible to change the color of a data series within a chart when it exceeds a value of another data series? Thanks!! Hi see: http://peltiertech.com/Excel/Charts/format.html#CondChart and http://peltiertech.com/Excel/Charts/format.html#CondChart2 -- Regards Frank Kabel Frankfurt, Germany "Robby" <Robby@discussions.microsoft.com> schrieb im Newsbeitrag news:03E95BC9-B246-41E9-A941-177C2C22CB4F@microsoft.com... > Is there any way possible to change the color of a data series within a chart > when it exceeds a value of another data series? > > Tha...

Test for a value on a subform
I have a form with a subform. The user is suppose to complete a response for all of the Result fields in the subform. Each subform will hav a variable number of Result records. I want to test for the existence of a result and, if null, prompt the user to go back and complete the form. the code below is close, but not quite there. Any help? Thanks 'Test for values in all Result field on open subform 'For N = 1 to MaxQuestionNumber 'CurrentResult = ("[Result]", "tblAuditQuestionResults", "[QuestionNumber] = N") ' If IsNull CurrentR...

MobileAdmin Cannot be displayed
Downloaded and installed the ActiveSync Web Admin Tool from the Microsoft site on my SBS03 Prem with Exchange SP2 Server. I then goto http://localhost/MobileAdmin and get HTTP Error 404 - File or directory not found. Also try https:// as well as using the server name instead of localhost - all give the same results. Have re-run the installation and still not luck. Has anyone had this problem yet? Look in IIS admin to see if the MobileAdmin folder was created. If not, you'll need to reinstall. "Joeskimon" <Joeskimon@discussions.microsoft.com> wrote in message news:D69...

Select Records based another table...
This may be very elementary, but i can't wrap my brain around it. I have tried to dummy it down as much as i can for myself, with plans of adapting it into something working. I have three tables that look like the following: Tbl 1: ProdID A B C 1 $1 $2 $3 2 $4 $5 $6 3 $7 $8 $9 Tbl 2: RmNum ProdID 1 3 1 2 2 1 2 2 Tbl 3: RmNum Style 1 A 2 C Relationships are: [tbl1 ProdID] ------ [tbl2 ProdID] [tbl2 RmNum] ...

display no seconds in time format [h]
Have used the [h] mm ss formatting to add up times over 24 hours but only want to display the hh mm and not the seconds (ss) the format option does not seem available, any ideas gratefully received. Hi Format>Cells>Number>Custom and in the white pane just type [h]:mm Regards Roger Govier Finolac wrote: >Have used the [h] mm ss formatting to add up times over 24 hours but only >want to display the hh mm and not the seconds (ss) the format option does not >seem available, any ideas gratefully received. > > ...

Combo Box to display only "active" records
Hi, I have a combo box based on a list of records in table. Overtime I may want to "de-activate" (Employee.Active=No) records in the list so that a user can longer chose it from the list, but I don't want previously selected records from list to be affected. I added a WHERE Employee.Active=Yes condition to the row source. My drop-down list no longer displays inactive records, but when I look at previous entries the record displayed is also blank. How do I only get this to apply to new records being created? Thanks Yes, that's a common scenario, Nancy. One ...

Multi-Select List Box Does Not Retain Selected Items
I created an Outlook Form in 2003. But when I select items in the list box they do not remain select when I select another control on the form. Any suggestions? Did you bind the list box to a keywords field? -- Sue Mosher, Outlook MVP Author of Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "kaykay" <anonymous@discussions.microsoft.com> wrote in message news:276dd01c4638d$bd5af590$a501280a@phx.gbl... > I created an Outlook Form in 2003. But when I select > items i...