Currently I am able to use a texbox to search through the listbox only when the multiselect property is set to none. But when I change the property to simple or extended my function doesn't work. Please see below
Function - Public Function CheckListbox(strPass As String, lstPersons As ListBox)
-
-
Dim intCurrIndex As Integer
-
-
Dim intStringLen As Integer
-
-
-
-
intStringLen = Len(strPass)
-
-
-
-
For intCurrIndex = 0 To lstPersons.ListCount - 1
-
-
If Left$(lstPersons.ItemData(intCurrIndex), intStringLen) = strPass Then
-
-
Exit For
-
-
End If
-
-
Next intCurrIndex
-
-
-
-
lstPersons = lstPersons.ItemData(intCurrIndex)
-
-
End Function
Calling the function - Private Sub abSearchtbox_KeyPress(KeyAscii As Integer)
-
Select Case KeyAscii
-
-
Case Asc(" ") To Asc("z")
-
-
strStringTyped = Me.abSearchtbox.Text & Chr(KeyAscii)
-
-
Case 8
-
If strStringTyped > "" Then
-
strStringTyped = Left$(strStringTyped, Len(strStringTyped) - 1)
-
End If
-
End Select
-
-
-
CheckListbox strStringTyped, Me.allAddressBooklbox
-
-
End Sub
-
I also tried another method but neither work when the multi select property is not none. I can't search at all.
Any Ideas??
3 1967 ADezii 8,834
Recognized Expert Expert
Hello xraive, I'm a little confused at to what you are trying to accomplish here. Please explain in detail, providing all relevant information.
Sorry Adezii,
I currently have a listbox and would like to be able to search the records. I have a textbox setup so that when the user enters a key an item matching it in the listbox would be selected. This would be similar to the autoexpand feature on the combo box. I would like to be able to have a user type in a string and the first Item matching that string be selected from the listbox. I hope I made myself a little clear. I can attach a sample db of what I am doing if you like.
Thanks for your time ADezii
ADezii 8,834
Recognized Expert Expert
This should point you in the right direction: -
Private Sub abSearchTBox_KeyPress(KeyAscii As Integer)
-
Dim strStringTyped As String
-
Dim intCurrIndex As Integer
-
Dim intStringLen As Integer
-
-
'Clear ALL Selections with each Keystroke
-
For intCurrIndex = 0 To allAddressBooklbox.ListCount - 1
-
allAddressBooklbox.Selected(intCurrIndex) = False
-
Next
-
-
strStringTyped = Me.abSearchTBox.Text
-
-
Select Case KeyAscii
-
Case Asc(" ") To Asc("z")
-
strStringTyped = strStringTyped & Chr(KeyAscii)
-
Case 8
-
If strStringTyped <> "" Then
-
strStringTyped = Left$(strStringTyped, Len(strStringTyped) - 1)
-
End If
-
Case Else
-
KeyAscii = 0 'CANCEL the Keystroke?
-
End Select
-
-
intStringLen = Len(strStringTyped)
-
-
For intCurrIndex = 0 To allAddressBooklbox.ListCount - 1
-
If Left$(allAddressBooklbox.ItemData(intCurrIndex), intStringLen) = strStringTyped Then
-
allAddressBooklbox.Selected(intCurrIndex) = True
-
Exit For
-
End If
-
Next intCurrIndex
-
End Sub
-
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Colleyville Alan |
last post by:
I have an app that looks up an id number and when a button is clicked,
inputs the id # into a query. After running the query, I click a second
button which grabs the client name rather than the id for input to another
operation.
Originally, I had a drop-down box with the client name and the client id
number and it worked fine, but it was for a demo and was quick-and-dirty.
For the real app, there are over 1,700 client ids and the...
|
by: Alvey Sidecast |
last post by:
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
|
by: Simon P |
last post by:
Hello group, I'm in desperate need of help. Here goes :
I have the following tables : CONTACTS (ContactID, FirstName,
LastName, Company, etc.), SHOWS (ShowID, ShowDescription) and
SHOWDETAILS (links the previous tables together so not to have a
many-to-many relationship -- has the ContactID and ShowID fields).
I have a main form with a couple of listboxes which are used for
querying the CONTACTS table. The results populate bound fields...
|
by: Colleyville Alan |
last post by:
I have a incremental search box that has been working fine for a couple of
months but is now acting up. This search box is from the cd that comes with
Getz's book, so I did not write it and have only a superficial understanding
of how it works.
I have had some trouble in the past when my code goes to another form and
comes back sometimes the search function did not work properly. Then I
added a line to requery it and it worked fine. ...
|
by: Alan Lane |
last post by:
Hello world:
I'm using Access 2003. I have 2 listboxes. One is a single column.
The other has two columns. I can use Dev Ashish's code (thanks Dev!) from
the Access MVP Website to accumulate the values from the bound column of a
MultiSelect listbox, so that I can include them in a SQL query that will
then be the recordsource for a report. This gives me 2 of the 3 values I
need to put into the SQL query. However, I can't get the non...
| |
by: RBohannon |
last post by:
I have a multi-selectable listbox named lstTitles.
In the OnClick event I had the following:
If Not IsNull(Me.lstTitles) Then
' do something with list selection
Else
' do something else
End If
This worked when I wrote it and has continued to work since...until
|
by: tshad |
last post by:
Can you do a search for more that one string in another string?
Something like:
someString.IndexOf("something1","something2","something3",0)
or would you have to do something like:
if ((someString.IndexOf("something1",0) >= 0) ||
((someString.IndexOf("something2",0) >= 0) ||
|
by: tshad |
last post by:
I cannot seem to get the asp:textbox to use classes. Style works fine. I
am trying to set the textbox to act like a label in some instance so it
doesn't have a border, readonly and the background is grey.
I have a class set as:
..table2Label{
border-style:none;
background-color:#F6F6F6;
}
|
by: Matthew Wells |
last post by:
I have a listbox set to simple multi select. For this example, users only
select one item at a time. I have command buttons on the form for First,
Previous, Next, Last, New (record). The form and listbox are unbound. The
listbox rowsource is a value list. The list box has about sixty items in
it. Each item in the list box corresponds to a record in the database.
When a user selects a row in the list box, the record is retrieved. The...
|
by: kaosyeti via AccessMonster.com |
last post by:
hey... i have an unbound multiselect listbox on a form that i want to use to
populate text boxes on that form. so if a user selects the 3rd item in a
list of 20, how can i have that item show up in a text box? then, how can i
have a second selected item show up in a different text box, without
affecting the 1st one? (lboxOptions, txtboxOptions0, txtboxOptions1, etc..)
--
Greg
Message posted via AccessMonster.com
|
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 most users, this new feature is actually very convenient. If you want to control the update process,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |