473,466 Members | 1,548 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

DLookUP Problem

kcdoell
230 New Member
Hello:

I am trying to do a Dlookup expression but it is not working. Basically I have 3 cascading combo box, with the first that has the following code set in the afterupdate event:

Expand|Select|Wrap|Line Numbers
  1. 'When the Division is selected, the appropriate Working Region list will
  2. 'display in the drop down list of CboWrkReg
  3.  
  4.     With Me![cboWrkReg]
  5.       If IsNull(Me!cboDivision) Then
  6.         .RowSource = ""
  7.          Else
  8.             .RowSource = "SELECT DISTINCT [WrkRegID] " & _
  9.                    "FROM TblJntALL " & _
  10.                    "WHERE [DivisionID]=" & Me!cboDivision
  11.  
  12.     End If
  13.      Call .Requery
  14. End With
  15.  
  16. End Sub
  17.  
  18.  
This works but it is showing the WrkRegID (Num) instead of the WrkRegionName (Text). My table " TblJntALL " is joining my many to many relationships between Division Name and Working Region Name.

How would I get it to display the WrkRegionName if the WrkRegionName is ONLY in my table “tblWrkReg”???

Any help would be great.

Thanks,

Keith.
Mar 17 '08 #1
8 1743
FishVal
2,653 Recognized Expert Specialist
Hi, Keith.

You need to use [TblJntALL] joined with [tblWrkReg].
Expand|Select|Wrap|Line Numbers
  1. .RowSource = "SELECT DISTINCT tblWrkReg.WrkRegID, " &_
  2.                    "tblWrkReg.WrkRegionName " & _
  3.                    "FROM TblJntALL INNER JOIN tblWrkReg " & _
  4.                    "ON TblJntALL.WrkRegID = tblWrkReg.WrkRegID " & _
  5.                    "WHERE [DivisionID]=" & Me!cboDivision
  6.  
Regards,
Fish
Mar 17 '08 #2
kcdoell
230 New Member
Hello:

I posted the followiing:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub CboDivision_AfterUpdate()
  3.  
  4. 'When the Division is selected, the appropriate Working Region list will
  5. 'display in the drop down list of CboWrkReg
  6.  
  7.     With Me![cboWrkReg]
  8.       If IsNull(Me!cboDivision) Then
  9.         .RowSource = ""
  10.          Else
  11.          .RowSource = "SELECT DISTINCT tblWrkRegion.WrkRegID, " & _
  12.          "tblWrkRegion.WrkRegionName " & _
  13.          "FROM TblJntALL INNER JOIN tblWrkRegion " & _
  14.          "ON TblJntALL.WrkRegID = tblWrkRegion.WrkRegID " & _
  15.          "WHERE [DivisionID]=" & Me!cboDivision
  16.     End If
  17.      Call .Requery
  18. End With
  19.  
  20. End Sub
  21.  
  22.  
But the ID number is still displaying. Any ideas??

Thanks,

Keith
Mar 17 '08 #3
FishVal
2,653 Recognized Expert Specialist
Hi, Keith.

I guess the table field bound to [cboWrkReg] contains values from tblWrkRegion.WrkRegID. Am I right?
If so, then you need a multicolumn combobox.
In design view set the values of [cboWrkReg] properties to the following:
ColumnCount = 2
ColumnWidths = 0;<any non-zero value here>
BoundColumn = 1

Kind regards,
Fish

P.S. Why do you use DISTINCT predicate? Are there duplicated joints in the table?
Mar 17 '08 #4
kcdoell
230 New Member
Fish:

Thanks for getting back to me, I needed to step away to catch the train. Now I am back looking at this problem again. In my Join table I do have multiple entries due to the relationships. That is why I used the select distinct.

I am going to look at the bound properties now.

Thanks,

Keith
Mar 18 '08 #5
kcdoell
230 New Member
Hi, Keith.

I guess the table field bound to [cboWrkReg] contains values from tblWrkRegion.WrkRegID. Am I right?
If so, then you need a multicolumn combobox.
In design view set the values of [cboWrkReg] properties to the following:
ColumnCount = 2
ColumnWidths = 0;<any non-zero value here>
BoundColumn = 1

Kind regards,
Fish

P.S. Why do you use DISTINCT predicate? Are there duplicated joints in the table?

Fish:

You were correct! I set the columncount=2 and boom I saw the names. I never join tables like you did before.

Thanks a lot.......

I actually had this working but needed to change my tables since I discovered that 3 of my tables had many to many relationships. When I changed that, then my cascading problems surfaced again. In the past, I never had to create a DB with lots of relationships let alone many to many ones.

Thanks again,

Keith
Mar 18 '08 #6
FishVal
2,653 Recognized Expert Specialist
Hi, Keith.

I would like to pay your attention to what that sounds like a design problem (or maybe not.

..... In my Join table I do have multiple entries due to the relationships. That is why I used the select distinct......
As long as the table implementing many-to-many relationship between two others contains only unique combinations of FKs from that two tables, filtering by one from these FKs will return recordset containing no duplicates of the other FK.
If it is not so, then it may cause many unpredictable faults in future.

To prevent this I'm strongly recommending you to set multifield index ensuring the table to contain only unique combinations of FKs.

Regards,
Fish
Mar 18 '08 #7
kcdoell
230 New Member
Hi, Keith.

I would like to pay your attention to what that sounds like a design problem (or maybe not.....................................
To prevent this I'm strongly recommending you to set multifield index ensuring the table to contain only unique combinations of FKs.

Regards,
Fish

I am new at creating many to many relationships but this DB has put me in that situation. I believe that I have my tables set correctly. I will research multifield indexing but the link did not help me to understand it entirely............

The reality is that I have to move this project forward and I think the relationships are tight but me not being an expert, that might be a bold statement...
Mar 18 '08 #8
FishVal
2,653 Recognized Expert Specialist
I am new at creating many to many relationships but this DB has put me in that situation. I believe that I have my tables set correctly. I will research multifield indexing but the link did not help me to understand it entirely............

The reality is that I have to move this project forward and I think the relationships are tight but me not being an expert, that might be a bold statement...
Index is just a database engine mechanism to "hold inventory" on a table.
One of it aspects useful in your case that it can prevent information duplicating in table.

In table design view
  • right-click to enter context menu
  • choose [Indexes...]
  • add to the first column new index name whatever you like
  • add to the second column field names expected to be the parts of the index (both FKs)
  • set Unique to Yes
  • voile, the database engine itself will prevent FK combination duplication, sure you need to remove existing duplicates first

Regards,
Fish
Mar 18 '08 #9

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

Similar topics

2
by: Ronny Sigo | last post by:
Hello all, I already put the same question, only now I have more to tell ... Although I used this code before in the same routine (only the fieldname of the table differs) ___ at this point in the...
0
by: Tony Williams | last post by:
I have posted a number of posts in the Access newsgroups concerning my problem with DLookup. I have had a number of the experts with helpful suggestions but I still can't get it to work! This is...
2
by: ctyrrell | last post by:
I have read with interest the many discussions of the 3048 Error: Cannot open any more databases. I understand how the number of open Table ID's causes the problem. My question has to do with the...
8
by: Christine Henderson | last post by:
I have a problem using the above function in the following simplified circumstance: In the lookup table called "Klms Travelled" I have 3 fields, eg: Receiver Name Receiver Suburb ...
6
by: Don Sealer | last post by:
I've written this expression for a DLookup function. It works almost alright. What I'm trying to do is type in a description and the ID field (number) populates automatically. It works almost as...
11
by: MLH | last post by:
DLookup("", "tblPreliminaryVINs", "=Forms!frmVINODO!SerialNum") is giving me a Type Mismatch error. That's confusing to me and I don't know how to circumvent it. The field in...
2
by: chris.thompson13 | last post by:
I am having a problem setting the criteria part of the DLookup method correctly and am consequently getting an error message. I have a database of staff duties, part of which is a query (qryDaily)...
2
by: Don | last post by:
Can someone help me fix my DLookup problem. I'm far from proficiency with Access. I've been creating databases for several years for work with the help of many of you and trial and error. I have...
2
by: boyleyc | last post by:
Hi all the following code works perfectly well. Basically it populates a series of check boxes on my form, depending on whether dlookup finds an associated record. The problem i have is that...
15
by: rleepac | last post by:
This is a little complicated but I'll do my best to explain. In my db I have a table called L_AgeCorrection which has the following fields: Age, Sex, Frequency, AgeValue This is a table used to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...
1
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
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.