473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

choose item in a ComboBox as we Type the contained text...

17
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
Mar 23 '15 #1

✓ answered by jforbes

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:
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  Option Explicit
  3.  
  4.  Private bLookupKeyPress As Boolean
  5.  
  6.  Private Sub cboLookup_Change()
  7.      Dim sSQL As String
  8.      Dim sNewLookup As String
  9.  
  10.      If Not bLookupKeyPress Then
  11.          sNewLookup = Nz(Me.cboLookup.Text, "")
  12.          sSQL = "SELECT Field2 FROM [tblBunchOfStuff] "
  13.          If Len(sNewLookup) <> 0 Then
  14.             sSQL = sSQL & " WHERE Field2 LIKE '*" & sNewLookup & "*'"
  15.          End If
  16.          Me.cboLookup.RowSource = sSQL
  17.          Me.cboLookup.Dropdown
  18.      End If
  19.      bLookupKeyPress = False
  20.  End Sub
  21.  
  22.  Private Sub cboLookup_KeyDown(KeyCode As Integer, Shift As Integer)
  23.      Select Case KeyCode
  24.          Case vbKeyDown, vbKeyUp
  25.              bLookupKeyPress = True
  26.          Case Else
  27.              bLookupKeyPress = False
  28.      End Select
  29.  End Sub
  30.  
  31.  Private Sub cboLookup_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  32.      bLookupKeyPress = True
  33.  End Sub
  34.  
  35.  
Be sure to set the AutoExpand Property to No.

6 1586
jforbes
1,107 Expert 1GB
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:
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  Option Explicit
  3.  
  4.  Private bLookupKeyPress As Boolean
  5.  
  6.  Private Sub cboLookup_Change()
  7.      Dim sSQL As String
  8.      Dim sNewLookup As String
  9.  
  10.      If Not bLookupKeyPress Then
  11.          sNewLookup = Nz(Me.cboLookup.Text, "")
  12.          sSQL = "SELECT Field2 FROM [tblBunchOfStuff] "
  13.          If Len(sNewLookup) <> 0 Then
  14.             sSQL = sSQL & " WHERE Field2 LIKE '*" & sNewLookup & "*'"
  15.          End If
  16.          Me.cboLookup.RowSource = sSQL
  17.          Me.cboLookup.Dropdown
  18.      End If
  19.      bLookupKeyPress = False
  20.  End Sub
  21.  
  22.  Private Sub cboLookup_KeyDown(KeyCode As Integer, Shift As Integer)
  23.      Select Case KeyCode
  24.          Case vbKeyDown, vbKeyUp
  25.              bLookupKeyPress = True
  26.          Case Else
  27.              bLookupKeyPress = False
  28.      End Select
  29.  End Sub
  30.  
  31.  Private Sub cboLookup_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  32.      bLookupKeyPress = True
  33.  End Sub
  34.  
  35.  
Be sure to set the AutoExpand Property to No.
Mar 23 '15 #2
Anbusds
17
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,
Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo83_Change()
  2. Dim sNewLookup As String
  3. If Not bLookupKeyPress Then
  4. sNewLookup = Nz(Me.Combo83.Text, "")
  5. sSQL = "SELECT Product from dbo.Customer_Item"
  6. If Len(sNewLookup) <> 0 Then
  7. sSQL = sSQL & " WHERE Product LIKE '*" & sNewLookup & "*'"
  8. Debug.Print sSQL
  9. End If
  10. Me.Combo83.RowSource = sSQL
  11. Me.Combo83.Dropdown
  12. End If
  13. bLookupKeyPress = False
  14.  
  15.  
  16. End Sub
  17.  
  18. Private Sub Combo83_KeyDown(KeyCode As Integer, Shift As Integer)
  19. Select Case KeyCode
  20. Case vbKeyDown, vbKeyUp
  21. bLookupKeyPress = True
  22. Case Else
  23. bLookupKeyPress = False
  24. End Select
  25.  
  26. End Sub
  27.  
  28. Private Sub Combo83_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  29. bLookupKeyPress = True
  30. End Sub
Thanks in advance...
Mar 24 '15 #3
jforbes
1,107 Expert 1GB
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:
Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2. 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:
Expand|Select|Wrap|Line Numbers
  1. Dim sSQL As String
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:
Expand|Select|Wrap|Line Numbers
  1. 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.
Mar 24 '15 #4
Anbusds
17
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...
Mar 25 '15 #5
jforbes
1,107 Expert 1GB
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.
Mar 25 '15 #6
Anbusds
17
Hi JForbes,
Its Working well now...
Thank you!!!
Apr 1 '15 #7

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

Similar topics

1
by: freddy | last post by:
I would like to load items to a combobox from a text file.
1
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
0
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...
13
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...
2
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...
9
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 ( ...
0
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...
3
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...
2
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.