473,503 Members | 2,157 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Easy Combobox ?

1,892 Recognized Expert Top Contributor
I'm trying to hard code values to a combo box using the following code:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2. Me.cmbPrinter.AddItem "Item1"
  3. Me.cmbPrinter.AddItem "Item2"
  4.  
  5. End Sub
I have the the Row Source Type set to Value List. When the form loads nothing is added to the combo box. What am I missing here?

Thanks,
Aric
Nov 6 '06 #1
7 2354
Tanis
143 New Member
You need the On Not In List event of the combo box. Look around, there are plenty of examples.
Nov 6 '06 #2
missinglinq
3,532 Recognized Expert Specialist
If you're hard wiring these values in, why bother putting them in code? Why not simply enter them under Row Source i.e.

"Item1";"Item2";"Item3" etc.
Nov 6 '06 #3
AricC
1,892 Recognized Expert Top Contributor
I have Row Source Type = Value List then Row Source = "Item1";"Item2";"Item3" still nothing shows.
Nov 6 '06 #4
AricC
1,892 Recognized Expert Top Contributor
I also tried: ( Not working )
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmbPrinter_NotInList(NewData As String, Response As Integer)
  2. Me.cmbPrinter.AddItem "Item1"
  3. Me.cmbPrinter.AddItem "Item2"
  4. End Sub
Nov 6 '06 #5
AricC
1,892 Recognized Expert Top Contributor
Never mind PEBKAC error.
Nov 6 '06 #6
MMcCarthy
14,534 Recognized Expert Moderator MVP
I also tried: ( Not working )
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmbPrinter_NotInList(NewData As String, Response As Integer)
  2. Me.cmbPrinter.AddItem "Item1"
  3. Me.cmbPrinter.AddItem "Item2"
  4. End Sub
AddItem doesn't work in standard VBA. Try this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub cmbPrinter_NotInList(NewData As String)
  3. Dim strRowSrc As String
  4.  
  5.   ' you can only add one item at a time
  6.   strRowSrc = Me.cmbPrinter.RowSource
  7.   Me.cmbPrinter.RowSource = strRowSrc & ";'" & NewData & "'"
  8.   Me.cmbPrinter.Requery
  9.  
  10. End Sub
  11.  
  12.  
Nov 7 '06 #7
NeoPa
32,557 Recognized Expert Moderator MVP
Never mind PEBKAC error.
Wrong Keyboard? or should that be PEBOAC?
Nov 7 '06 #8

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

Similar topics

13
2742
by: Mr. B | last post by:
Here's the situation... You've a combobox with Items already added. Say they look like this (or even lines of text): 10-00-232 10-00-256 10-01-006 10-01-213 10-02-200
7
8484
by: Nicolae Fieraru | last post by:
Hi All, I am trying to change the rowsource of a combobox when I click on it. I played with many events, associated with the form and the combobox, but still haven't figured out what is the way...
8
12066
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
1
2478
by: anonymous | last post by:
I've been trying to put a them, please help me out. Here's the major parts of my code: public Form1() { DataSet myDataSet = new DataSet("myDataSet"); DataTable testTable = new...
18
39961
by: Mike Bartels | last post by:
Hi Everyone! I have two Arrays A and B. Both arrays are byte arrays with 7 bytes each. The contents of array A and B are the same A = {1, 2, 3, 4, 5, 6, 7}; B = {1, 2, 3, 4, 5, 6, 7}; When...
1
1293
by: Michael Rodriguez | last post by:
I have a table that has a field called FinancialType. It has two possible values, F and S, which stand for Financial and Statistical, respectively. What I want is a ComboBox that has two drop...
3
6805
by: TT (Tom Tempelaere) | last post by:
Hay there, I'm writing my own DataGridComboBoxColumn because .NET 1.1 does not have one (I hope .NET 2.0 supplies one). I based it on this article:...
4
4602
by: jon f kaminsky | last post by:
Hi- I've seen this problem discussed a jillion times but I cannot seem to implement any advice that makes it work. I am porting a large project from VB6 to .NET. The issue is using the combo box...
6
2841
by: dbuchanan | last post by:
VS2005 I've been reading all the help I can on the topic (MSDN, other) but I can't make sense of this. Desired behavior; The user is to choose from the displayed list of the databound combobox...
6
1035
by: active | last post by:
I have the following at the start of a class. Seems to me I could delete everything except the New method. Is that correct? I can't imagine why not but since the IDE put it there I'd like...
0
7093
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
7287
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,...
0
7349
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...
1
7008
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7467
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
5594
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
3177
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1521
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 ...
0
399
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...

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.