473,785 Members | 2,327 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

filter combo box to show unique names in linked table

59 New Member
Hello,
I have a data entry form for a table with information about buildings and am having a problem making a combo box do what I want. I would like to make the combo box show a list of unique bldg mgmt company names and then to open a building management company form to show all records with this name, so the user can find the correct branch location to select. Then, upon closing the building management company form, the active/selected record will be returned in the combo box on the buildings form.

The main form is called frmBldgs. The table that frmBldgs is based on is called tblBldgs.
tblBldgs includes:
Field 1: BldgID – autonumber primary key
Field 2: BldgNm – name of the building
Field 3: BldgMgmtCoIDFK – foreign key linking to a table about the building mgmt company
… and a number of other attributes about the building.

The table detailing the Building Management Company is called tblBldgMgmtCo.
tblBldgMgmtCo includes:
Field 1: BldgMgmtCoID – autonumber primary key
Field 2: BMCNmIDFK – foreign key linking to a table listing building mgmt company names
Field 3: Addr1IDFK – foreign key linking to a table listing street addresses

The reason I have a separate building mgmt company name table is that there can be more than one company with the same name (e.g. branch locations with different addresses).

The table listing the Bldg Mgmt Company names is called tblBldgMgmtCoNm .
tblBldgMgmtCoNm includes:
Field 1: BMCNmID – autonumber primary key
Field 2: BldgMgmtCoName – unique company name

On frmBldgs I have a combo box, called cboBldgMgmtCo, with control source BldgMgmtCoIDFK. Right now, cboBldgMgmtCo shows building names, but it shows all unique records in tblBldgMgmtCo, which means that bldg mgmt company names repeat if there is more than one branch (with a different address and therefore a different record).
The current row source query for cboBldgMgmtCo is:
Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT tblBldgMgmtCo.BldgMgmtCoID, tblBldgMgmtCoNm.BldgMgmtCoName
  2. FROM tblBldgMgmtCoNm INNER JOIN tblBldgMgmtCo ON tblBldgMgmtCoNm.BMCNmID = tblBldgMgmtCo.BMCNmIDFK
  3. ORDER BY tblBldgMgmtCoNm.BldgMgmtCoName;
  4.  
Column Count is 2
Column Width is 0”;1”
Bound Column is 1
This results is the name of the building mgmt companies are listed in the combo box, but – as I mentioned above – there are repeats if more than one record in tblBldgMgmtCo has the same name.

I have also added an AfterUpdate Event for cboBldgMgmtCo to open the building management company form, called frmBldgMgmtCo (based on tblBldgMgmtCo). The code is as follows:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cboBldgMgmtCo_AfterUpdate()
  2.     Dim stDocName As String
  3.     Dim stLinkCriteria As String
  4.  
  5.     stDocName = "frmBldgMgmtCo"
  6.  
  7.     stLinkCriteria = "[BldgMgmtCoID]=" & Me![cboBldgMgmtCo]
  8.     DoCmd.OpenForm stDocName, , , stLinkCriteria
  9.  
This opens frmBldgMgmtCo to the record with the same BldgMgmtCoID, but does not show all records with the same bldg mgmt company name.

I want cboBldgMgmtCo to list the potential building mgmt company names once each and then open frmBldgMgmtCo filtered to show all records with that name (BMCNmIDFK) so the user can find the correct branch to select. The user can then select the correct BldgMgmtCo record (or create a new one) and when they close frmBldgMgmtCo, the active / selected record will be returned in cboBldgMgmtCo on frmBldgs.

To do this, I assume I need to change the query for the row source to somehow only show unique names, though I cannot quite figure out the correct code. Then, I think I need to change the AfterUpdate event so that it will open frmBldgMgmtCo filtered to the field BMCNmIDFK of the bldg mgmt company that equals the name chosen in the combo box. Finally, I need a button on frmBldgMgmtCo to close the form, once the correct record is selected and add an OnClick Event to this that returns the correct record in cboBldgMgmtCo on frmBldgs. I have a button that closes the form, called btnClose,but have not created the code to ensure the correct record is returned in the combo box.

I am new to VBA and Access and so need help on how to write the code to achieve these ends. Any help is greatly appreciated! Thanks in advance.

Bridget
Oct 16 '07 #1
2 3895
nico5038
3,080 Recognized Expert Specialist
Hmm, it won't be possible to have a "Distinct Name" combobox and position later on one specific company as the needed CompanyID won't (can't) be present in the combobox.

Personally I would however take an entirely different approach.
I would create an "unbound" (not table related) Mainform ans all companies as subform. Then I would place the company "distinct" combobox on the mainform and use the afterupdate event to filter the subform.
Besides the subform you can add "Action" buttons like [Add], [Update], [Delete], [Print], etc..
For the filtering it's perhaps even better to explain the use of the right-click popup to filter, as that's even more versatile. It will allow a LIKE '*inc* selection.

Checkout my sample database:
http://www.geocities.com/nico5038/xS...tAction-97.zip
and my right-click instruction I give my users:
http://www.geocities.com/nico5038/xR...nstruction.zip

Nic;o)
Oct 17 '07 #2
banderson
59 New Member
Hmm, it won't be possible to have a "Distinct Name" combobox and position later on one specific company as the needed CompanyID won't (can't) be present in the combobox.

Personally I would however take an entirely different approach.
I would create an "unbound" (not table related) Mainform ans all companies as subform. Then I would place the company "distinct" combobox on the mainform and use the afterupdate event to filter the subform.
Besides the subform you can add "Action" buttons like [Add], [Update], [Delete], [Print], etc..
For the filtering it's perhaps even better to explain the use of the right-click popup to filter, as that's even more versatile. It will allow a LIKE '*inc* selection.

Checkout my sample database:
http://www.geocities.com/nico5038/xS...tAction-97.zip
and my right-click instruction I give my users:
http://www.geocities.com/nico5038/xR...nstruction.zip

Nic;o)
Hello Nic;o,
Thank you for your response. Sorry for my delayed reply. I was pulled onto another project for a few days. (and, of course, it takes a while to get your head back into the Access world once you've taken a break!)

I will take a look at your sample database to see how its functionality might work for me and will repost if I have questions.
Thanks again,
Bridget
Oct 19 '07 #3

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

Similar topics

3
6615
by: Richard | last post by:
Hi, I have a form based on a table. When I filter the form I want to run a report based on the same table with the same filter as the form. No problem until I want to filter a combo box where the text value is on a different table. The me.filter is then a text instead of the id-number from the lookup table. This causes the report to prompt for the parameter. How do I get by this problem? Do I need to create a temporary table? I rather...
1
1896
by: Access User | last post by:
Here is my situation: I have two tables linked together in a many-to-many relation through an interum table. It looks like this... Title TitleTopic Topic ----- ---------- ----- TitleKey-------| TitleTopicKey |--------TopicKey TitleName |-----TitleID | TopicName CreationDate TopicID------------| CreationDate
6
4629
by: Ralph2 | last post by:
Some time ago with a lot of help from this group I made a reasonably successful database to keep track of our shop drawings. However the searching mechanism is too complicated for the occasional user and I would like to change the whole process. I would like to duplicate the layout of my form... but each field becomes a simple "searching" ListBox. On completing any one search field all the rest are filtered to this value. Subsequent...
3
12503
by: Stewart | last post by:
Hi all! My (relatively small) database holds data on staff members and the projects (services) that they are assigned to. In my form frmStaff, I have a list of staff members - it is a continuous form. Each staff member is linked to a Service through a many-to-many relationship, using a junction table called jctStaffServices. I would like to place a Combo Box in frmStaff where you can 'filter' staff by the Service (i.e. ServiceName)...
11
6112
by: Bob | last post by:
I am in the process of upgrading an Access database to SQL Server (and climbing that learning curve!). The wizard happily upgraded all the tables and I can link to them OK using ODBC. The application controls allocation of revisions to aircraft maintenance manuals for an airline type operation. In the application there is a form loaded at start-up allowing the user/s to select the records that they are currently interested in from 4...
7
2191
by: Takeadoe | last post by:
Gang, I have searched this group and have found several other occasions where folks have experienced the same problem that is described below. "I have access to several databases where I have used the filter by form button to find the records I require. I some databases the drop down combo box that results has all the different options within that field that
2
2646
by: Pablo | last post by:
I have a Continuous Form based on the following table: sku, description, categoryId, subCategoryId I restrict the initial dataset to include one value for categoryId, but it may include differing valuse for subCategoryId. The user needs to be able to modify either Category or SubCategory. I have placed two combo boxes on the form, they are query based and linked to the two Id columns. The cboCategory displays category names
5
1522
by: favor08 | last post by:
I have a database and I am using a function that captures the shortname and displays it on the mainMenu screen. What I want to do is filter the information on the "past due" screen based on the person who has just open the database so that they can see just their items. The shortname is stored in a table called "TShortNames" The shortname ties to an 4 character "Opid". This same "opid' is in the main "TARA" table that stores all the...
2
2899
by: jambonjamasb | last post by:
What I am trying to do is have a combo box which allows me to filter for a certain field in a subform. I can't think how to do this and have tried with the follwoing code. Basically the field in question is : POL_Change_Allocated - This is a yes/no tick box. I want to filter for all forms where the tick hasn't been applied. (Am I right in thinking that this means this field is no unless ticked?) The main form feeds from table OCP Base...
0
9647
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9489
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10356
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10100
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9959
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5396
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5528
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4061
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.