Connecting Tech Pros Worldwide Forums | Help | Site Map

Type Ahead Code for Access 2003

Newbie
 
Join Date: Dec 2008
Posts: 2
#1: Dec 15 '08
I have been trying to use this code to enable the type ahead function in a combo box within a form that I am using. The combo box contains the id#, old compound number and new compound number. What is the simplest way to enable the type ahead function?



This is the code I am using:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cboCompound_Number_Change()
  2. Dim strTyped As String
  3.   Dim strSelect As String
  4.   strTyped = Nz(cboCompoundNumber.Text, "")
  5.   If Len(strTyped) = 3 Then
  6.     strSelect = "SELECT CompoundList.ID, NewPMXCompoundNumber, OldPMXCompoundNumber FROM CompoundList " & _
  7.        "WHERE CompoundNumber LIKE """ & strTyped & "*"" " & _
  8.        "ORDER BY CompoundNumber;"
  9.        cboCompoundNumber.RowSource = strSelect
  10.        End If
  11. End Sub
  12.  
This is my first time writing code and using Access. The easier the better.

Any assistance will be appreciated.

Thanks

missinglinq's Avatar
Moderator
 
Join Date: Nov 2006
Location: Richmond, Virginia USA
Posts: 3,000
#2: Dec 15 '08

re: Type Ahead Code for Access 2003


You don't need any VBA code! The Auto Expand property, what you are calling "type ahead function" is the default for comboboxes, and if it's been turned off, can be turned on again by selecting the combobox and going to Properties - Data and setting Auto Expand to Yes.

Your duplicate posting of this question/problem has been deleted! Please refrain from this prohibited behavior in the future.

From FAQs

Do Not Double Post Your Questions

Double posting is where you start a thread on a topic and then for some reason start another thread on exactly the same topic in the same forum. Please do not do this because

1. It makes it very hard for people to answer you especially if there are answers happening in all the threads you have started because they have to read 2 or more threads in order to see what has already been said.

2. It swamps the forum with your problem resulting in less attention for the other threads.

If you feel for some reason that you post has been overlooked (for instance it hasn't had any replies) please do not repost the question. Post a message to the thread you started, this will bump it back to the top of the thread list for the forum.

Thank you for your attention in this matter.

Welcome to Bytes!

Linq ;0)>

Moderator
Newbie
 
Join Date: Dec 2008
Posts: 2
#3: Dec 15 '08

re: Type Ahead Code for Access 2003


Thank you! It works fine!

My first time posting. Sorry for the double posts.
Reply