473,513 Members | 3,317 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Listbox prob: Selecting the selected row

This is probably embarrassingly simple, but I've been trawling through
this ng for hours now and my brain hurts.

I've got an unbound multi-column listbox (multi-select=none) whose
rowsource is a query based on a combobox selection. After the
selection is made from the combobox the listbox may, or may not, have
records in it. If it doesn't, no problems, I've got;

If Me.lbxContacts.ItemsSelected.Count = 0 Then

to handle that. But when there *are* multiple rows returned I want to
select a row and take the value of column 4 from the selected row to
use in a strCriteria statement. Something like;
strCriteria = "[ConSurname] = '" & Me!lbxContacts.Column(4,r) & "'"

The thing that's caused me to stop dead is that I can't find a way to
get the value/count of the highlighted row. Can someone please point
me in the right direction?
cheers
Nov 13 '05 #1
1 4995
Since the listbox is not multiselect, it will return simply return a value
from the selected row. To get the value of a different column than the Bound
Column, you would use the Column statement. Specifying the row won't be
necessary. You'll get the value from the selected row if you don't specify.
The problem you are probably running into is that the Column property is
zero based. This means that the first column is zero, the second is one, the
third is two, and the fourth (the one you want) is three.

strCriteria = "[ConSurname] = '" & Me!lbxContacts.Column(3) & "'"

Also, judging by the name of your field, the values are Surnames. You are
enclosing the value in single quotes because the value is a string. This is
normally correct; however, surnames can contain apostrophes (i.e. O'Hare)
and if you have some like this, it will break your code. It is possible to
change it to double quotes to solve this problem, but it is harder to read.

strCriteria = "[ConSurname] = """ & Me!lbxContacts.Column(3) & """"
or
strCriteria = "[ConSurname] = " & Chr(34) & Me!lbxContacts.Column(3) &
Chr(34)

--
Wayne Morgan
MS Access MVP
"Alvey Sidecast" <al************@yahoo.com> wrote in message
news:ed**************************@posting.google.c om...
This is probably embarrassingly simple, but I've been trawling through
this ng for hours now and my brain hurts.

I've got an unbound multi-column listbox (multi-select=none) whose
rowsource is a query based on a combobox selection. After the
selection is made from the combobox the listbox may, or may not, have
records in it. If it doesn't, no problems, I've got;

If Me.lbxContacts.ItemsSelected.Count = 0 Then

to handle that. But when there *are* multiple rows returned I want to
select a row and take the value of column 4 from the selected row to
use in a strCriteria statement. Something like;
strCriteria = "[ConSurname] = '" & Me!lbxContacts.Column(4,r) & "'"

The thing that's caused me to stop dead is that I can't find a way to
get the value/count of the highlighted row. Can someone please point
me in the right direction?
cheers

Nov 13 '05 #2

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

Similar topics

10
21823
by: SueB | last post by:
Hi. Is there a way to "unselect" items in a listbox, programmatically? Here's what I want to do (and I've been trying to to this while debugging the form, but I've been unsuccessful) ... I have a form with two listboxes. The form, also, has two option buttons in an options group: 1 button for
3
3525
by: Alpha | last post by:
I have 3 radio buttons for include, exclued or 'select all' from the listbox items. If a user selects the 'Select All' button' then all items in listbox is hi-lited as selected. Now, when user selects one item out of the 'all selected' listing then there is now only one item selected. How and where can I put in some code to change the...
0
1253
by: Namespace | last post by:
Hi I am having trouble selecting more than one value as selected in a listbox through code. The property "ListSelectionMode.Multiple" is set. There is no problem selecting manually (CTRL + listitem) from the listbox. I have a value-string (seperated by komma) which I want to display in a listbox through code (VB.NET). Only the last value in...
9
2094
by: Larry Serflaten | last post by:
I'm drawing my own inherited listbox, and I don't want the user to select any items, but I do want to allow them to scroll the listbox. When they click on an item, there is a flicker of the previously selected item and the new selected item. Even though I don't show anything selected, the default behaviour wants to redraw those items. ...
18
1996
by: Dave Sauny | last post by:
Ok, its a friday, I'm at work and I cant get this to work: I have 3 listboxes on one tab control page. when i select an item in listbox1 i want whatever is selected on the other 2 listboxes unselected. when listbox2 is selected, 1 and 3 should have no items selected and the same with listbox 3. Sounds simple... should be simple! I have...
2
4071
by: Hitesh | last post by:
I have a listbox and the values get selected (highlighted) from code. I can highlight the corresponding list box items, but they do not show in the listbox I have to scroll through the list box to find them. How can I setFocus on the highlighted data items in the listbox after they are highlighted. The selection mode is set to multiple for...
9
3202
by: zdrakec | last post by:
Hello all: Clearly, I'm not getting it! Here is the scenario: On a web page, I have two list boxen and a text box. The first listbox is populated at page load time (if it is not a postback). This listbox has AutoPostback = True. When the user selects an item from this list, the second listbox is populated with more items relevant to this...
7
5582
by: Lit | last post by:
Hi, How can I capture the vertical scroll bar position for a Listbox. I have a Listbox of 100 items + when I click on it I post back remove the item selected. After returning to the client browser the list box scroll position is at the top.
2
4415
by: vinod allapu | last post by:
hi all, i am trying to generate a report, iam using sql server 2000 and Asp.net 2.0. First to select the columns iam using the list box... as we can order by the query result from the selected columns only, i want to use another list box which contains only selected columns.. 1. Iam filling the columns names required into...
0
7269
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7177
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7394
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7559
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7123
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5100
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4756
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3248
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
811
muto222
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.