Dear All,
I have 1 combobox containes 2 columns from 1 table now i want to select record from the list
Example: i want to select PM-1234-1111 so i dont want to type starting letter PM to select but i want to type 234 or 123 or somewhere in the middle or end to filter that contained text in all the items is it possible?
Thanks in advance...
Anbu
Here is a link to a very similar question: http://bytes.com/topic/access/answer...-selected-item
I took the code from that Question and added an asterisk to the Where Clause and it seems to be doing what you want, or at least close: -
Option Compare Database
-
Option Explicit
-
-
Private bLookupKeyPress As Boolean
-
-
Private Sub cboLookup_Change()
-
Dim sSQL As String
-
Dim sNewLookup As String
-
-
If Not bLookupKeyPress Then
-
sNewLookup = Nz(Me.cboLookup.Text, "")
-
sSQL = "SELECT Field2 FROM [tblBunchOfStuff] "
-
If Len(sNewLookup) <> 0 Then
-
sSQL = sSQL & " WHERE Field2 LIKE '*" & sNewLookup & "*'" -
End If
-
Me.cboLookup.RowSource = sSQL
-
Me.cboLookup.Dropdown
-
End If
-
bLookupKeyPress = False
-
End Sub
-
-
Private Sub cboLookup_KeyDown(KeyCode As Integer, Shift As Integer)
-
Select Case KeyCode
-
Case vbKeyDown, vbKeyUp
-
bLookupKeyPress = True
-
Case Else
-
bLookupKeyPress = False
-
End Select
-
End Sub
-
-
Private Sub cboLookup_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
-
bLookupKeyPress = True
-
End Sub
-
-
Be sure to set the AutoExpand Property to No.
6 1587
Here is a link to a very similar question: http://bytes.com/topic/access/answer...-selected-item
I took the code from that Question and added an asterisk to the Where Clause and it seems to be doing what you want, or at least close: -
Option Compare Database
-
Option Explicit
-
-
Private bLookupKeyPress As Boolean
-
-
Private Sub cboLookup_Change()
-
Dim sSQL As String
-
Dim sNewLookup As String
-
-
If Not bLookupKeyPress Then
-
sNewLookup = Nz(Me.cboLookup.Text, "")
-
sSQL = "SELECT Field2 FROM [tblBunchOfStuff] "
-
If Len(sNewLookup) <> 0 Then
-
sSQL = sSQL & " WHERE Field2 LIKE '*" & sNewLookup & "*'" -
End If
-
Me.cboLookup.RowSource = sSQL
-
Me.cboLookup.Dropdown
-
End If
-
bLookupKeyPress = False
-
End Sub
-
-
Private Sub cboLookup_KeyDown(KeyCode As Integer, Shift As Integer)
-
Select Case KeyCode
-
Case vbKeyDown, vbKeyUp
-
bLookupKeyPress = True
-
Case Else
-
bLookupKeyPress = False
-
End Select
-
End Sub
-
-
Private Sub cboLookup_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
-
bLookupKeyPress = True
-
End Sub
-
-
Be sure to set the AutoExpand Property to No.
Hi JForbes,
Thanks for your reply, i have tried a few times after i follow your code i am not able to select that column from my table...
so total 3 event procedure anything wrong with my code...
Code as follows, - Private Sub Combo83_Change()
-
Dim sNewLookup As String
-
If Not bLookupKeyPress Then
-
sNewLookup = Nz(Me.Combo83.Text, "")
-
sSQL = "SELECT Product from dbo.Customer_Item"
-
If Len(sNewLookup) <> 0 Then
-
sSQL = sSQL & " WHERE Product LIKE '*" & sNewLookup & "*'"
-
Debug.Print sSQL
-
End If
-
Me.Combo83.RowSource = sSQL
-
Me.Combo83.Dropdown
-
End If
-
bLookupKeyPress = False
-
-
-
End Sub
-
-
Private Sub Combo83_KeyDown(KeyCode As Integer, Shift As Integer)
-
Select Case KeyCode
-
Case vbKeyDown, vbKeyUp
-
bLookupKeyPress = True
-
Case Else
-
bLookupKeyPress = False
-
End Select
-
-
End Sub
-
-
Private Sub Combo83_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
-
bLookupKeyPress = True
-
End Sub
Thanks in advance...
I'm a little fuzzy about what error you are getting, if any. So I'm guessing the DropDownList for the ComboBox is not displaying for you.
There are two things that I noticed that you might want to check.
The first is to include these two lines at the top of your Form: - Option Explicit
-
Private bLookupKeyPress As Boolean
I'm pretty sure these are missing as you should be getting an error in Combo83_Change() since it is missing the following:
The other thing is that you mentioned you have two columns in your ComboBox but the example has only one. You may need to add the additional column into the Select String: - sSQL = "SELECT Product from dbo.Customer_Item"
and/or make sure the ComboBox Properties ColumnCount and BoundColumn line up with the RowSource that is being created.
Hi JForbes,
Thanks for your reply...
Still the same issue occurs so i used table/query in the properties to lookup the table, i am not going to use VBA to lookup the table, is it possible to use filter here any VBA Code?
Thanks in advance...
What issue are you having? What is it doing? Is there an error message?
Filtering a ComboBox RowSource is not a function available in Access. That is why the code sets the RowSource, which is effectively the same.
Hi JForbes,
Its Working well now...
Thank you!!!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: freddy |
last post by:
I would like to load items to a combobox from a text file.
|
by: ReidarT |
last post by:
I have a databound combobox that opens with the first record in the dataset.
I want to have an empty combobox or a text 'Select text'.
regards
reidarT
|
by: |
last post by:
Hello NG!
I try to call a WebService from a mobile device. The WebService should
return a DataSet, so the call looks like
mDataSet = mWebSrv.GetDataSet(<Params>)
but instead of returning a...
|
by: =?Utf-8?B?S2VzdGZpZWxk?= |
last post by:
Hi
Our company has a .Net web service that, when called via asp.net web pages
across our network works 100%! The problem is that when we try and call the
web service from a remote machine, one...
|
by: vanea |
last post by:
Hy.
I have a little problem with a comboBox on my form, and i want to ask if anyone could help me. I'm writing a DB application and i am populating my comboBoxes with an ArrayList object and a...
|
by: Steve |
last post by:
Hi;
I've being going through some legacy code on an old JSP site I have
been patching. I noticed that when I save the JSP down to my PC as an
HTML file I get this javascript error in IE 6 ( ...
|
by: robert112 |
last post by:
Hi All,
I have a .net WSE 3.0 Web Service acting as a client calling a j2EE
web Service. The service works when I call it using a client program
called soapUI (which is free to download) but when...
|
by: Benjamin Anthony |
last post by:
Hi i have a very little knowledge of HTML
I am Doing my School Project and need a help.
I want to link a combobox to a textbox
say if i select a value from the combobox a particular text should...
|
by: doubts85 |
last post by:
i have problem when i try build this application and the error is below.
Client found response content type of 'text/html; charset=utf-8', but expected 'text/xml'.
The request failed with the...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
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...
|
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,...
|
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...
|
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...
|
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...
|
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...
|
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,...
| |