473,385 Members | 1,645 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,385 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 9158
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.