Solved

Go to specified row of a combo box with check boxes

Posted on 2011-03-22
9
352 Views
Last Modified: 2012-05-11
On MS Access 2007 my combo box allows multiple selections, providing check boxes for the selections.  How can I allow user to quickly go to a desired row of the combo box? --e.g., go to the rows of the field that begin with letter "P"? ( This is not a problem with a simple combo box that doesn't allow multiple sections; you put the curser in a row of the field, and enter the first letter of the first word in the field.) I have attached a Word picture of the opened combo box. GOTO-desired-row-of-a-combo-box.docx
0
Comment
Question by:Tucker22
  • 4
  • 3
  • 2
9 Comments
 
LVL 28

Expert Comment

by:omgang
Comment Utility
One option is to add a new first column to the combo box row source.  Make it the same as the current second column.  You'll have that column included twice.  Set the column width for the first column to 0.01" or something.  Make sure to adjust the bound column setting so it is still on the column you want.
OM Gang
0
 

Author Comment

by:Tucker22
Comment Utility
This would not allow me to use the "Allow Multiple Values" property for the combo box (with check boxes to select the values), and move to the desired row by entering the first letter of that row's text value.
0
 
LVL 28

Expert Comment

by:omgang
Comment Utility
Please post the row source for the combo box in question.
OM Gang
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 167 total points
Comment Utility
This is what I would consider yet another drawback to using these "Multi Valued fields"
http://allenbrowne.com/Access2007.html#Mixed

Even though the Autoexpand property is set to yes, this does not seem to work because the checkbox seems to always be the first visible column (what the autoexpand property usually picks up on)

The theory being, if you are going to use multiselect fields, then you want to select more than 1 Value,
...hence, no need to "Jump" to a value like you can in a "Single" value filed" (standard combobox).


JeffCoachman
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:Tucker22
Comment Utility
To Omgang: Thank you for trying to help; maybe you will have a further suggestion.  Here is the row source:

SELECT [LkUpPart63MACTReq].[Part63_subpart_short_name], [LkUpPart63MACTReq].[MajorArea] FROM [LkUpPart63MACTReq];

I had already combined the original two fields--the field having "A" to "ZZZZ" values with the field that is the "short name" of the Subpart.  I did this because I wanted the combo box selections to update the associated table with both of these values, and selections from a combo box can populate only one field of a table--as far as I know.

 I might give up on allowing multiple selections from this particular  combo box (which has long rows of text, as it seems to adversely affect (1) selecting options , and (2) the readability of the values when they are placed in one field.  But maybe you will have another suggestion that works well.
0
 
LVL 28

Assisted Solution

by:omgang
omgang earned 333 total points
Comment Utility
<<and selections from a combo box can populate only one field of a table--as far as I know.>>
Not so.  It's true that a combo box can have only one bound column that can be assigned to a field in the underlying table.  However, there is nothing to stop us from populating many other table fields (via code, macro, etc.) with the values from the other columns in the combo box.  In general we don't do this becuase the it goes against normalization:  if we can store one value in a table and lookup related values from other tables (or via calculation) then we should only store the single value in our table.
OM Gang
0
 
LVL 28

Assisted Solution

by:omgang
omgang earned 333 total points
Comment Utility
Tucker22, I can't figure it out either.  I have never used multi valued fields and am thinking boag2000 is on to it for why this doesn't work.  Here's what I've tried and it functions as expected up to the point of trying to set focus onto an item in the list.  Each approach I attempt results in an error.


Option Compare Database
Option Explicit

Public blKeyPressed As Boolean

Private Sub Category1_KeyDown(KeyCode As Integer, Shift As Integer)
On Error GoTo Err_Category1_KeyDown

    Dim i As Integer
    Dim x As String
    Dim vVal As Variant
   
    blKeyPressed = False
   
        'check value of public key press variable an only proceed if it is False
    If blKeyPressed = True Then GoTo Exit_Category1_KeyDown
   
        'capture key press character
    x = Chr$(KeyCode)
   
    For i = 0 To Me.Category1.ListCount - 1
        If Left(Me.Category1.ItemData(i), 1) = x Then

            'Me.Category1.ItemData(i).Select
       
            'vVal = Me.Category1.ItemData(i).Column(0)
       
            'Me.Category1.ItemData(i).SetFocus
           
            'vVal = Me.Category1.ItemData(i)
            'Me.Category1.Value = vVal        
   
            Exit For
        End If
    Next

        'set public key press variable to true so we don't repeat this for every key press
    blKeyPressed = True
   
Exit_Category1_KeyDown:
    Exit Sub

Err_Category1_KeyDown:
    MsgBox Err.Number & ", " & Err.Description, , "Error in Sub Category1_KeyDown of VBA Document Form_frmCategory"
    Resume Exit_Category1_KeyDown
End Sub
0
 

Author Closing Comment

by:Tucker22
Comment Utility
Thanks to OM Gang & Jeff Coachman.  Your comments convinced me to create multiple combo boxes rather than allowing multiple entries to one combo box.  It's a less sophisticated method and takes up more space on the form, but it'll be easy for users to enter data and the design can be easily maintained.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
Comment Utility
To be fair, ...yes the Multiselect value/field/combobox is slick...

But remember, it has real flaws:
http://allenbrowne.com/Access2007.html#Mixed
http://support.microsoft.com/kb/926701

IMO, the biggest draw back is that it glosses over one the most crucial relationships in database design, ...The Many-to-Many relationship.

By doing this it shortchanges new Access developers of this critical skill.

Remember, if you rely to heavily on MVF's, and do not learn these basic concepts, you will be at a distinct disadvantage when it comes time to upgrade to SQL Server.
As of now, these MVF's *DO NOT* import into SQL Server.
So you may have to  redesign key parts of your application all over again from scratch.

Finally keep in mind that Database professionals have been successfully designing these types of relationships and interfaces for over 50 years, ...long before MVF's in MS Access.


;-)

JeffCoachman
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now