473,396 Members | 1,775 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Combo Box Lists

First off - I am not very technical when it comes to this (well, or any)program, so explain it as you would to a child <vbg>>

Currently I have three tables with accompanying forms for 2 of them - they are tbl_breeds, tbl_clubs and tbl_rescues

They have a field in common - "breed" (no quotes)

I am using a combo box in the forms (for the club and rescue tables) for the "breed" value. How do I set it up so that the combo box (record source would be "tbl_breeds") is automatically populated with those form entries which are not already included in the breeds table?

I am currently using Access 2003.

I had an old database someone had set up for me that did something similar but I cannot duplicate it. There were several references to "SELECT DISTINCTROW"

Hope this makes sense and someone can help me out!

Thanks in advance,

RLynn
Jan 26 '07 #1
11 1991
MMcCarthy
14,534 Expert Mod 8TB
First off - I am not very technical when it comes to this (well, or any)program, so explain it as you would to a child <vbg>>

Currently I have three tables with accompanying forms for 2 of them - they are tbl_breeds, tbl_clubs and tbl_rescues

They have a field in common - "breed" (no quotes)

I am using a combo box in the forms (for the club and rescue tables) for the "breed" value. How do I set it up so that the combo box (record source would be "tbl_breeds") is automatically populated with those form entries which are not already included in the breeds table?

I am currently using Access 2003.

I had an old database someone had set up for me that did something similar but I cannot duplicate it. There were several references to "SELECT DISTINCTROW"

Hope this makes sense and someone can help me out!

Thanks in advance,

RLynn
Try this ...

Expand|Select|Wrap|Line Numbers
  1. SELECT Q.Breed
  2. FROM  (SELECT Breed FROM tbl_clubs UNION
  3. SELECT Breed tbl_Rescues GROUP BY Breed) As Q
  4. RIGHT JOIN tbl_breeds As B
  5. ON Q.Breed = B.Breed
  6. WHERE B.Breed Is Null;
  7.  
Jan 27 '07 #2
Thanks - where/exactly how do I enter the code??
Jan 27 '07 #3
MMcCarthy
14,534 Expert Mod 8TB
Thanks - where/exactly how do I enter the code??
In the properties of the combobox put this in the Row Source property
Jan 27 '07 #4
I added that code to the Row Source property of the Clubs form (which is for the tbl_clubs)

The Combo box is not not populated with anything (completely blank when I click on the arrow instead of a list corresponding to the breed field in tbl_breeds), and does not add new entries to the tbl_breeds

:(
Jan 27 '07 #5
MMcCarthy
14,534 Expert Mod 8TB
I added that code to the Row Source property of the Clubs form (which is for the tbl_clubs)

The Combo box is not not populated with anything (completely blank when I click on the arrow instead of a list corresponding to the breed field in tbl_breeds), and does not add new entries to the tbl_breeds

:(
Not the Record Source of the Form but the Row Source of the combobox.
Jan 27 '07 #6
Not the Record Source of the Form but the Row Source of the combobox.
Yes - that's where I put it. The Row Source of the combo box (for the breed field) on the Clubs form.
Jan 27 '07 #7
MMcCarthy
14,534 Expert Mod 8TB
Yes - that's where I put it. The Row Source of the combo box (for the breed field) on the Clubs form.
Check the column widths property. What is that set to?
Jan 27 '07 #8
column widths for that is 1"
Jan 27 '07 #9
MMcCarthy
14,534 Expert Mod 8TB
column widths for that is 1"
Sorry just rethought the logic. You might have to change RIGHT JOIN to LEFT JOIN as follows:

Expand|Select|Wrap|Line Numbers
  1. SELECT Q.Breed FROM (SELECT Breed FROM tbl_clubs UNION SELECT Breed tbl_Rescues GROUP BY Breed) As Q LEFT JOIN tbl_breeds As B ON Q.Breed = B.Breed WHERE B.Breed Is Null;
  2.  
Jan 27 '07 #10
Thanks for the help.

I managed to find the following at databasedev.co.uk - and so far it's working!:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cboBookCategory_NotInList(NewData As String, Response As Integer)
  2.  
  3.     Dim strSQL As String
  4.     Dim i As Integer
  5.     Dim Msg As String
  6.  
  7.     'Exit this sub if the combo box is cleared
  8.     If NewData = "" Then Exit Sub
  9.  
  10.     Msg = "'" & NewData & "' is not currently in the list." & vbCr & vbCr
  11.     Msg = Msg & "Do you want to add it?"
  12.  
  13.     i = MsgBox(Msg, vbQuestion + vbYesNo, "Unknown Book Category...")
  14.     If i = vbYes Then
  15.         strSQL = "Insert Into tblBookCategories ([strBookCategory]) " & _
  16.                  "values ('" & NewData & "');"
  17.         CurrentDb.Execute strSQL, dbFailOnError
  18.         Response = acDataErrAdded
  19.     Else
  20.         Response = acDataErrContinue
  21.     End If
  22. End Sub
  23.  

Ouch - I think I hurt something trying to get this done!
Jan 27 '07 #11
NeoPa
32,556 Expert Mod 16PB
If I understand this correctly, it will add entries that the operator types in rather than list those missing from the Breeds table that are found in either of the other two tables. This may be what you require, but if so this seems different from what you were asking for in your original post.
The first response, other than the use of RIGHT JOIN instead of LEFT JOIN, was a perfect answer to your question as far as I could understand it. If this is still what you actually want then I suggest you try Mary's latest SQL as it should do the job for you.
If you find that the code better fits your need then that's a different matter of course. I'm glad you found a solution anyway - whichever you prefer in the end.
Jan 27 '07 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Sami | last post by:
Am not really clear on differences and preferences for looking up person / acct by key number using one of these. Preferred - list or combo? Please explain in detail why. Thanks!
3
by: joni b | last post by:
I need help limiting the options shown in a combo box. I have two combo boxes that appear in a datasheet view subform. The form looks like an Excel spreadsheet, which is what the user prefers....
1
by: Matt | last post by:
Here is my problem. I am trying to get a combo box working that lists all the models of servers that we have. This combo box is just one of many text boxes that I have on my form. I am running a...
6
by: Brian Henry | last post by:
Here's an example of the code.. I have two combo boxes on screen that when one's selection is change the other's items will be updated to reflect the change (based on a relation) Private...
2
by: taras.di | last post by:
Hi everyone, I've been reading up on how to create a drop down box who's context is dynamically produced based on the value of a previous select box. I've read a lot about some of the browsers...
1
by: Meaney | last post by:
Hi, I have a form with 4 combo boxes. They are used for selecting SchoolName (lists 28 names), LocationName (lists 4 geographic locations), EquipmentName (lists 14 equipment types) and...
0
by: Tom | last post by:
I have some very strange issues with combo boxes on a tab control. Here's the scenario: I have a Windows Forms form that has a tab control on it, with two (2) tabs. Tab 2 happens to have a number...
1
by: Shawn Yates | last post by:
It has been a while since I have done anything on MS Access and I seem to be a bit rusty. I hope someone could help me solve my issue. I have a form that has multiple combo boxes on it. Each box...
8
by: AA Arens | last post by:
Hi I do have a products table and products-parts table in my Access 2003 database and log all services into a form. I do have at least the following two combo boxes on my form: - Choose...
3
kcdoell
by: kcdoell | last post by:
I have 5 cascading combo boxes on a form. Below is a sample of my vb in the first combo box: Private Sub CboDivision_AfterUpdate() 'When the Division is selected, the appropriate Segment...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.