473,472 Members | 2,163 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Easy combo box question

I have another question for the community, and hopefully it's an easy
one. It seems ridiculously simple, but I can't find anything on it.

I have a combo box that is bound to a table. When a form is opened, I'd
like the current value of said combo box to be dictated by a value given
by the previous form. For the life of me, I can't figure out how to use
code to set the current value of a combo box. Here is the simple code,
taken right from a book, that I'm trying to work with.

Dim i As Integer

With Me!cboCustomer
For i = 0 To .ListCount - 1
If .Column(3, i) = Me!tboCustomerNumber Then
.Selected(i) = True <----------------------------------
Exit For
End If
Next i
End With

The line with the arrow pointing to it is where it breaks down, as the
code was written for a list box. A combo box has no .Selected property,
and I can't find anything that is its equivalent.

Any help would be greatly appreciated.

Mason

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #1
2 1792
Try a global constant possibly CustNo as Long. This must be declared in an
indipendent Module (ie one not bound to a form.
Assuming the bound column in the Combo box is bound to tboCustomerNumber,
then OnClose of the previous form set CustNo = tboCustomerNumber and OnOpen
of the new form set Me!ComboBox = CustNo.

Phil

"Mason Wood" <ma***@codemonkey.cc> wrote in message
news:3f*********************@news.frii.net...
I have another question for the community, and hopefully it's an easy
one. It seems ridiculously simple, but I can't find anything on it.

I have a combo box that is bound to a table. When a form is opened, I'd
like the current value of said combo box to be dictated by a value given
by the previous form. For the life of me, I can't figure out how to use
code to set the current value of a combo box. Here is the simple code,
taken right from a book, that I'm trying to work with.

Dim i As Integer

With Me!cboCustomer
For i = 0 To .ListCount - 1
If .Column(3, i) = Me!tboCustomerNumber Then
.Selected(i) = True <----------------------------------
Exit For
End If
Next i
End With

The line with the arrow pointing to it is where it breaks down, as the
code was written for a list box. A combo box has no .Selected property,
and I can't find anything that is its equivalent.

Any help would be greatly appreciated.

Mason

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #2


Thanks for the response, Phil. Worked great!

Mason

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: NB | last post by:
Let's say in the product table I have around 50,000 products (well, infact it has now about 2000 only, but it's growing very fast, hence the question here) In the order form, users will select...
3
by: Marcus Canales | last post by:
Hello all, Here is my situation. I have a combo box on a form. The combo box is linked to a qry (qryCustomers) and the form is linked to tblOrders. The way I currently use the combo box is to...
8
by: Lyn | last post by:
Hi, Can anyone tell me how the initial value displayed in Combo Box is determined when a form is opened? I am loading the dropdown from one field ("CategoryName") of a table, with "ORDER BY ". ...
1
by: Adjo | last post by:
Okay, I've seen all the examples of using comboboxes on webforms when using simple values. And in the issue-tracker starterkit there is a way to use comboboxes with id/value foreign keys in a smart...
2
by: Gerry | last post by:
I have a combo box and I can populate it with my class of dat (the class allows me to store each userid,username called - see code below I want the user to select the dropdown and see the...
2
by: kaosyeti | last post by:
it may be because i'm having a BAD day but i can't come up with an easy way to do this... i want to have a form for recording one department's yearly forecasted data. what i have is a column of...
1
by: Shawn Yates | last post by:
It has been a while since I have done anything on MS Access and I seem to be a bit rusty. I hope someone could help me solve my issue. I have a form that has multiple combo boxes on it. Each box...
3
by: Isaac | last post by:
I have a database of employee's names -- if they are on a certain disciplinary level then a box called CAP is checked in the employee's name table. I have a form that has a combo list of...
2
by: Sid | last post by:
I need some help in setting up Access combo box. I am using three comboboxes in my form. Comb Box 1, Combo Box 2, Combo Box 3. The row source for each of the combo box is a seperate table. ...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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
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...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.