473,545 Members | 2,788 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Display Lookup Fields from Multi-Select List Box on a Report

1 New Member
Greetings,
This is my first post so I will try to be brief and accurate.
I have a report that uses 9 user selectable filters (Dates, Y/N's as Combo Boxes and 4 Multi-Select List Boxes. 2 of the Multi-Select Boxes acquire their data from other tables as Lookup's. All functions for the filters operate properly pulling the data needed. One of my options with the data is to send it to a Report that can be printed.
The request now comes to add the filters used to a cover page. That is all accomplished, EXCEPT for the Lookup's. The Bound ID number used is sent to the report instead of the Displayed selection. How can I get that Lookup to display on the report? Alternately, is their an easier way to do what I want that I overlooked?

Sample Code is below. In this code, modified from Allen Browne's Multi-Select List Box filter code, I create an Array that stores each selection from the Multi-Select List Box and sends it to a hidden text field. That field is shown on the cover page of the report. It's messy but works.
Expand|Select|Wrap|Line Numbers
  1. ...
  2.     Dim strWhere As String      
  3.     Dim lngLen As Long               
  4.  
  5.     Dim Criteria2 As String
  6.     Dim Criteria2Array() As String ' Array - Used to pass info to a Text Field.
  7.     Dim Criteria2dual As String ' Gathers looped data.
  8.  
  9.      For Each j In Me![List2].ItemsSelected
  10.            ReDim Criteria2Array(p To 150) As String
  11.       If Criteria2 <> "" Then
  12.          Criteria2dual = Criteria2dual
  13.          Criteria2 = Criteria2 & " OR "
  14.       End If
  15.           Criteria2Array(p) = Criteria2dual & Me![List2].ItemData(j)
  16.           Criteria2dual = Criteria2dual & Me![List2].ItemData(j) & ", "
  17.           Criteria2 = Criteria2 & "[CSS_CSM_Names]='" & Me![List2].ItemData(j) & "'"
  18.      Next j
  19.  
  20.        If Criteria2 > "" Then
  21.        Criteria2 = "(" & Criteria2 & ")"
  22.        strWhere = strWhere & Criteria2 & " AND "
  23.        MsgBox Criteria2Array(p)
  24.  
  25.          If Criteria2Array(p) <> "" Then
  26.          Me.List2Storage.Value = Criteria2Array(p)
  27.          Else
  28.          Me.List2Storage.Value = "All Selected"
  29.          End If   
  30.  
  31.     lngLen = Len(strWhere) - 5
  32.     If lngLen <= 0 Then    
  33.         MsgBox "You Have Selected All Files!", vbInformation, "Everything Selected"
  34.     Else  
  35.         strWhere = Left$(strWhere, lngLen)
  36.         Me.Filter = strWhere
  37.         Me.FilterOn = True
  38.     End If
Mar 4 '08 #1
1 4148
mshmyob
904 Recognized Expert Contributor
To reference another column in your drop down box use the 'COLUMN' property.

Expand|Select|Wrap|Line Numbers
  1. Me.txtBox.Value=Me.cboBox.Column(1)
  2.  
You would obviously change the control names. Column(1) refers to the 1st column (0 based - column 0 is your bound column which is usually the PK).

This is just an example. You just need to reference Column(1) in your report.

Here is another way to grab values from a multi selection list box

Expand|Select|Wrap|Line Numbers
  1. Dim lst1 As ListBox
  2. Dim lst2 As ListBox
  3. Dim itm As Variant
  4. Dim vSearchString As String
  5.  
  6.  
  7. Set lst1 = Me!lstPickFrom
  8. Set lst2 = Me!lstPickTo
  9.  
  10. For Each itm In lst1.ItemsSelected
  11. ' Set RowSource property for first selected item.
  12. If lst2.RowSource = "" Then
  13.   lst2.RowSource = lst1.Column(0, itm) & ";" & lst1.Column(1, itm) & ";" & lst1.Column(2, itm)
  14. Else
  15.  ' Check whether item has already been copied.
  16.     vSearchString = lst1.Column(0, itm) & ";" & lst1.Column(1, itm) & ";" & lst1.Column(2, itm)
  17.      If Not InStr(lst2.RowSource, vSearchString) > 0 Then
  18.         lst2.RowSource = lst2.RowSource & ";" & lst1.Column(0, itm) & ";" & lst1.Column(1, itm) & ";" & lst1.Column(2, itm)
  19.  
  20.      End If
  21. End If
  22. Next itm
  23.  
Here I picked up all columns from one list box and passed to another list box and populated it based on the values I picked from the 1st. You would just change it to pass them to your report or hidden controls as you indicated above.

cheers,
Mar 5 '08 #2

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

Similar topics

4
6390
by: Rob Allen | last post by:
I've got a lookup table for a lookup table and can't work out the SQL to do a search. Can anyone help? As an example, consider the following: Table 1 - books: fields: book_id, price, title, author data: 1, 2.99, 'Life', 'A. Slug' 2, 4.99, 'The Universe', 'A. Planet'
1
1982
by: J P Singh | last post by:
Hi All I have been given the task to create a search page to search on of the tables in the sql database. I have been asked that the user should be able to search any field(which I have done) but he should also be able to customise the form to display or hide any feilds in the results. My table has about 20 feilds and different users...
0
1287
by: maxal | last post by:
have two fields, Title_Id table customers, I also have table named titles with title_id and titles In DataSet I have DataTable customers with fields title_id and title. In the form I have combox that I binded to field title_id in table customers. It works fine, field title_id is updated correctly. However, field title remains the same. I...
10
13423
by: DettCom | last post by:
Hello, I would like to be able to display or hide fields based on whether a specific Yes/No radio button is selected. This is in conjunction with a posting a just made here in the same group related to checkboxes. Thanks!!!
2
1900
by: David Allison | last post by:
Should Lookup fields be replaced by table normalisation? Then the Tables brought together in a Query for a Form to be based on? -- Dave Allison ~ Scotland
13
2505
by: John Baker | last post by:
Hi: I have a general question about table access and look ups. Over simplifying things,and using a very theoretical example, lets say I have two tables; Client and Bill. The client table has a unique auto number (which is indexed) and the Client name, as well as address and other key data
3
10616
by: google | last post by:
I have a database with four table. In one of the tables, I use about five lookup fields to get populate their dropdown list. I have read that lookup fields are really bad and may cause problems that are hard to find. The main problem I am having right now is that I have a report that is sorted by one of these lookup fields and it only displays...
3
1358
by: Roland Wolters | last post by:
Hi, This tast seems so simple but I can't seem to crack it: I have some data in a dataset. I can bind the dataset to a datalist control and show the fieldvalues but i would have to hardcode the filednames. Problem is that I just want to show ALL the fields without knowing what table is loaded. I do not know what fields are present.
2
2157
by: computerider | last post by:
I have a standard two-table structure, Orders which has a lookup field to the Salesperson table. However when you build a form the salesperson field has the combo box feature - which I WANT when adding new orders BUT NOT when viewing existing orders (because you can actually change the salesperson by using it) - I am guessing I must use code (have...
2
2376
by: Lance Williams | last post by:
How can you programatically tell if a field in a table is a lookup field? I am looping through the fields collection and I want to see if any fields are lookup fields. Is there a property, or something taht will tell me if the field is a lookup field. I need to do this at the table level and not at the form level because if a field is a...
0
7499
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...
0
7689
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. ...
0
7943
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7786
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...
1
5359
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5076
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
1919
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
1
1044
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
743
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.