Results 1 to 4 of 4
  1. #1
    tsuchong is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2011
    Posts
    5

    How to make a form display only the selected value in a listbox.

    Hi all,



    1. I have a field set as a "List Box" with "value list" source.

    2. When a form is created however, it shows all the values of the list and highlights the selected one for each data.

    3. Is there a way to make the form only display the value that is selected?

    I've attached a picture to further illustrate what i mean.



    thanks

  2. #2
    maximus's Avatar
    maximus is offline Expert
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    Here I have a form, RecordSource Table Product. I have a combobox10 Rowsource Table Product. When I select a Product in the combobox only the particulars of that product will be displayed.

    1) You can use a Recordsetclone to display record select in a listbox or a combobox.

    Private Sub Combo10_AfterUpdate()
    Me.RecordsetClone.FindFirst "[Product_id] = " & Me.Combo10
    Me.Bookmark = Me.RecordsetClone.Bookmark
    End Sub

    2)Next option is changing the Recordsource of you Form.

    Private Sub Combo10_AfterUpdate()
    Dim strSQl As String
    strSQl = "Select * From tblProduct Where Product_id=" & Me.Combo10
    Me.RecordSource = strSQl
    End Sub

    3) Using Filter
    Private Sub Combo10_AfterUpdate()
    Dim strCriteria As String
    strCriteria = "product_id=" & Me.Combo10
    Me.Filter = strCriteria
    Me.FilterOn = True
    End Sub

    remember when using the 2nd and the 3rd method u need to reset the recordSource of the form or turn the filter option off to display all record again.

  3. #3
    tsuchong is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2011
    Posts
    5
    sorry this is too advanced for me.

    Can you guide me step by step on how do i do this?

    Thanks

  4. #4
    snorkyller is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2011
    Posts
    16
    Hi tsuchong,

    If the Current Location field was, on the form, a combo box instead of a list box, would it be ok for you? 'Cause a combo box is like a text box, displaying only the selected value, and the list would appear only if you click on it. To do so, you have to open the table in design mode, and change the DisplayControl property to List box instead of Combo box. Then If you delete the list box on the form, and add again the Current Location field, a combo box would now be created instead of a list box.

    Hope that this is what you need.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 9
    Last Post: 01-20-2011, 02:22 PM
  2. Selected items in listbox
    By tomodachi in forum Access
    Replies: 1
    Last Post: 09-09-2010, 01:14 PM
  3. Exporting report selected from a listbox to excel
    By GARCHDEA in forum Import/Export Data
    Replies: 1
    Last Post: 08-10-2010, 07:45 AM
  4. Replies: 6
    Last Post: 03-27-2010, 11:18 AM
  5. Replies: 0
    Last Post: 12-14-2009, 09:57 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums