473,410 Members | 1,908 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,410 software developers and data experts.

Combo: disable or grey out items in the list?

In Access 2003 I have a continuous form with a combo. I'm trying to find a way to change the displayed values of the combo depending on whatever value was selected in the combo in the previous record, whilst also displaying whatever value was seelcted in previous records, i.e. record one might have 5 as the value, which means the combo in the next record would include items 3,4 and 6; if the user then selects item 6, the next record would allow a choice of say 4, 6 and 10. I can't see a way to do this with the rowsource as any changes on one record are reflected in others, i.e. if I remove item 5 in record 2, then the field appears blank in record 1 (though the data is of course still there). I'm not too keen to work around it by placing a txt box on top of the combo as user loses the facility to go to an item by typing the first one or two characters; so I'm wondering whether anyone knows how to dim/grey out items in a combo as can be done with menus?

Many thanks
Sep 25 '07 #1
5 9164
FishVal
2,653 Expert 2GB
Hi, Kevin.

The solution may be the following.
Its rather simple but however it seems to work with combos where BoundColumn = Visible column only as it requires to set LimitToList property to No.

Tables:

tblItemNames
txtItemName Text, PK

tblItems
keyItemID AutoNumber, PK
txtItemName FK


Form:

RecordSource = "tblItems"

contains ComboBox [txtItemName]
txtItemName.RowSource =
Expand|Select|Wrap|Line Numbers
  1. SELECT tblItemNames.txtItemName FROM tblItemNames LEFT JOIN tblItems ON tblItemNames.txtItemName=tblItems.txtItemName WHERE tblItems.keyItemID Is Null; 
txtItemName.LimitToList = No

Form module:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_AfterUpdate()
  2.     Me.txtItemName.Requery
  3. End Sub
  4.  
Sep 25 '07 #2
FishVal
2,653 Expert 2GB
Accidently posted.
Sep 25 '07 #3
Hi, Kevin.

The solution may be the following.
Its rather simple but however it seems to work with combos where BoundColumn = Visible column only as it requires to set LimitToList property to No.

Tables:

tblItemNames
txtItemName Text, PK

tblItems
keyItemID AutoNumber, PK
txtItemName FK


Form:

RecordSource = "tblItems"

contains ComboBox [txtItemName]
txtItemName.RowSource =
Expand|Select|Wrap|Line Numbers
  1. SELECT tblItemNames.txtItemName FROM tblItemNames LEFT JOIN tblItems ON tblItemNames.txtItemName=tblItems.txtItemName WHERE tblItems.keyItemID Is Null; 
txtItemName.LimitToList = No

Form module:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_AfterUpdate()
  2.     Me.txtItemName.Requery
  3. End Sub
  4.  


Thanks FishVal,

Simple but clever, I wouldn't have thought of this. I'll see if I can think of some way to apply the principle so that I can still store the integer in my bound column whilst displaying my text value, one way or another.
Sep 25 '07 #4
I’ve come up with another solution which might be of interest to others, as this allows me to capture both the integer value in the field as well as the associated name string (and other fields when I use for real); and display the current name string value within each instance of the form, but change the row source for the combo control for each instance without visually disturbing the other records. I did have to resort to using a text box control as well as the combo control, but for my purposes that's better than storing a text string instead of an integer. Here’s what I did;

I placed a combo control with the following key properties;

Name: cboActionID
Control Source: ActionID (in my tblData)
Row Source: qryComboSource
Column Count: 2
Column Widths: 0cm;4.602cm
List Width:4.6cm
Width: 0.487cm
Left: 4.286cm
Scroll Bar Align: Left

I added a textbox control with the following key properties;
Name: txtActionName
Control Source: ActionName (in my tblData)
Left: 0.2cm
Width: 4.053cm

This simulates an ordinary combo control, so that the list drops down to the left, below the text box control.

I added code to the combo control as follows;

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Private Sub cboActionID_Enter()
  5.  
  6.     Dim MySQL As String
  7.     Dim CurrAction As Integer
  8.     Dim CurrName As String
  9.  
  10.     CurrName = Me.txtActionName
  11.     CurrAction = DLookup("[ActionID]", "tblActions", "[ActionName] = '" & CurrName & "'")
  12.  
  13.     MySQL = "SELECT tblActions.ActionID, tblActions.ActionName " & _
  14.     "FROM tblActions " & _
  15.     "WHERE (((tblActions.ActionID)=34 Or (tblActions.ActionID)=35 " & _
  16.     "Or (tblActions.ActionID)=36 Or (tblActions.ActionID)=39)) " & _
  17.     "UNION SELECT """ & CurrAction & """ AS ActionID, """ & CurrName & """ AS ActionName " & _
  18.     "FROM tblData WHERE ([tblData]![TableID]=[Forms]![frmData]![TableID]);"
  19.  
  20.     Me.cboActionID.RowSource = MySQL
  21.  
  22. End Sub
  23.  
  24. Private Sub cboActionID_Exit(Cancel As Integer)
  25.  
  26.     Me.cboActionID.RowSource = "qryComboSource"
  27.     Me.cboActionID.Requery
  28.  
  29. End Sub
I’ll need to finesse the way users interact with the text box so that this is in keeping with a combo, and also control for a null value, but otherwise I think this will do the job. Thanks again for your suggestion FishVal, it made me relook at an SQL solution rather than purely VBA, and stop thinking this had to be terribly complicated.
Sep 27 '07 #5
FishVal
2,653 Expert 2GB
Hi, Kevin.

Another possible solution may be this.
Dynamically generated form input fields
Oct 1 '07 #6

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

Similar topics

4
by: Yuk Cheng | last post by:
<<<start index.htm>>> <html> <head> <script> function perform(action){ } </script> </head>
1
by: Brad Allison | last post by:
This is a newbie question. I have a combo box in where the end user will select an item (an obedience class - yes for dogs, not for developers) and then assign an obedience judge to that class. ...
2
by: Robert | last post by:
Am using a nested continuous bound subform to add multiple records to the underlying table. One of the fields is based on a limit to list combo box. Any suggestions on best way to progressively...
2
by: G .Net | last post by:
Hi Is there a way to prevent the combo displaying its list of items when the "combo arrow" is clicked? The problem I'm trying to resolve is that depending on a Boolean value, which is set...
4
by: festerian | last post by:
Hi everybody - I'm a new access user and would appreciate some help. I'm trying to create a form, on which I'm trying to disable/enable a combo box, based on the value entered in another combo box...
11
Hiren Joshi
by: Hiren Joshi | last post by:
Hello All Experts, I am a Moderate VB Programmer. I am developing one Application at the moment with VB 6.0 and MS Access. Operating System is Win XP. Its a Multi User application. What I want...
2
by: y2ktan | last post by:
Hi Guys and Girls, I am building a windows application using VS2005, C#.net. Now, I have a combo box that contains a collection of elements. Thus, I want to grey out some of the elements in the...
2
by: Claudia Fong | last post by:
Hi, I added a tabcontrol in a panel in my form. My tabcontrol have more than 3 pages.. each page contains textboxes, combobox, checkbox. I want to disable the items of each of the page of...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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
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...

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.