473,399 Members | 4,254 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,399 software developers and data experts.

Using INNER JOIN to display the names instead of the IDs

kcdoell
230 100+
Hello:

I have a form that has 3 combo boxes.

CboDivision
cboWrkReg
cboCreditReg

In the Field Properties, of those combo boxes I used the “Default Value” to populate selections that were made via another form I created.

[Forms]![DataEntry]![CboDivision]
[Forms]![DataEntry]![cboWrkReg]
[Forms]![DataEntry]![cboCreditReg]

My problem is that the cboWrkReg & cboCreditReg are displaying the ID number instead of the Name that it is tied to it. Because the cboCreditReg needs to be a cascading combo box I put the following code into the Load Event of the form:

Expand|Select|Wrap|Line Numbers
  1. 'Private Sub Form_Load()
  2. 'When the Working Region is selected, the appropriate Credit Region list will
  3. 'display in the drop down list of CboCreditReg
  4.  
  5.   With Me![cboCreditReg]
  6.    If IsNull(Me!cboWrkReg) Then
  7.       .RowSource = ""
  8.     Else
  9.    .RowSource = "SELECT DISTINCT tblCreditRegion.CreditRegID, " & _
  10.          "tblCreditRegion.CreditRegionName " & _
  11.          "FROM TblLocationsMM INNER JOIN tblCreditRegion " & _
  12.          "ON TblLocationsMM.CreditRegIDFK = tblCreditRegion.CreditRegID " & _
  13.          "WHERE [WrkRegIDFK]=" & Me!cboWrkReg
  14.  
  15.     End If
  16.     Call .Requery
  17.   End With
  18. End Sub
  19.  
Now the cboCreditReg displays the name but I still have my cboWrkReg displaying the ID.

Is there a way that I can get both my cboWrkReg and cboCreditReg to display the names by modifying slightly my code??

Any assistance would be greatly appreciated.

Thanks,

Keith.
Mar 18 '08 #1
4 1934
janders468
112 Expert 100+
What is the rowsource for cboWrkReg? I could be wrong on but it appears that you're adding too much in your select statement. If you want only the region name then only use that in the select statement for instance:
SELECT DISTINCT tblCreditRegion.CreditRegID #
FROM TblLocationsMM INNER JOIN tblCreditRegion
ON TblLocationsMM.CreditRegIDFK = tblCreditRegion.CreditRegID " & _
WHERE [WrkRegIDFK]= & Me!cboWrkReg
The ID field does not need to be included in the select statement. That is just a guess though, the way you have presented the example it appears as though cboWrkReg shouldn't have anything and the cboCreditReg should show the ID. If you want all of your controls to be bound to the underlying query set your form's record source property to the query that contains the relevant data and then set the control's control source property to the relevant fields. If I've missed the point of it please clarify what you need, and I'll be more than happy to help.
Mar 19 '08 #2
kcdoell
230 100+
Hello:

I was playing with this and went a different way. I set the rowsource of my cbowrkreg to the following:

Expand|Select|Wrap|Line Numbers
  1. SELECT tblWrkRegion.WrkRegID, tblWrkRegion.WrkRegionName 
  2. FROM tblWrkRegion 
  3. WHERE (((tblWrkRegion.WrkRegID)=forms.dataentry.cbowrkreg)) 
  4. ORDER BY tblWrkRegion.WrkRegionName;
  5.  
Column count = 2
Column width = 0";1"

And it worked. It was easier than I thought......


thanks for the insight.


Keith.
Mar 19 '08 #3
janders468
112 Expert 100+
That will work, but forcing a combobox to have two columns and hiding the first seems a bit of an unnecessary work around, and will make the properties of the control unpredictable from a maintenance standpoint because the control appears to be something that it is not (a single column combobox). Just as philosophical/stylistic development point I wouldn't do that. I would only put the region column in your select statement and use only one column in the combobox which will then accurately reflect what you want. Obviously feel free to do it however you want, just giving some unsolicited advice ;-).
Mar 19 '08 #4
kcdoell
230 100+
That will work, but forcing a combobox to have two columns and hiding the first seems a bit of ...................... ;-).
Yes, but my other queries are looking for the ID number on that form and not the Name. That is why I have taken that path.. I am not an expert on design, so I tend to fall back on what I have learned and know works for me. I am thinking that I would have to double back on my other functionality if I was to change things and that would cost me time.....

Thanks for the help... :-)

Keith.
Mar 19 '08 #5

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

Similar topics

3
by: Ike | last post by:
Oh I have a nasty query which runs incredibly slowly. I am running MySQL 4.0.20-standard. Thus, in trying to expedite the query, I am trying to set indexes in my tables. My query requires four...
11
by: news-east.earthlink.net | last post by:
The scenario: two tables CustomerTable --------------- CustomerID OrderID CustomerName CustomerEmail
8
by: kieran | last post by:
Hi, I have the following sql statement. I originally had the statement with two INNER JOINS but in some situations was getting an error so changed the last INNER JOIN to a LEFT OUTER JOIN (as...
5
by: Ilan Sebba | last post by:
When it comes to adding records in related tables, Access is really smart. But when I try to do the same using ADO, I am really stupid. Say I have two parent tables (eg Course, Student) and one...
0
by: Jason | last post by:
I would like to be able to place a command button on a primary (parent) form that opens up a subform. I want to use this subform to search for or limit the recordset of data in the primary form. ...
52
by: MP | last post by:
Hi trying to begin to learn database using vb6, ado/adox, mdb format, sql (not using access...just mdb format via ado) i need to group the values of multiple fields - get their possible...
11
by: funky | last post by:
hello, I've got a big problem ad i'm not able to resolve it. We have a server running oracle 10g version 10.1.0. We usually use access as front end and connect database tables for data extraction....
3
by: Zeff | last post by:
Hi all, I have a relational database, where all info is kept in separate tables and just the id's from those tables are stored in one central table (tblMaster)... I want to perform a query, so...
3
by: 150563a | last post by:
I have a form that has 5 sub forms on it. I want to know how to reference the form properties of these sub forms. This I can do but what I am having trouble with is substituting the form name...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.