has an example for using IE's autocomplete in
a text box, and can be easily adapted for a combo box.
(must have IE5 or better)
If this is not what you are after, could you give more
details about what you want your program to do.
Good Luck *:->*
Lets see I have a program with names using vb and a combo box this is where i want to autocomplete the infomation. Do you see what I am talking about now. Thanks again for your help.
;-)Margaret
Ok Margaret, still not entirely sure if this is what you want...
But try this.
Set the Combo's "Sorted" property to True in the properties box.
Set the Combo's "Style" property to 2- Dropdown List.
Add all your names to the combo box.
e.g.
Private Sub Form_load()
'I added this blank item first so the combo is empty at start
Combo1.AddItem ""
Combo1.AddItem "Bort"
Combo1.AddItem "Bert"
Combo1.AddItem "Ben"
Combo1.AddItem "Barney"
Combo1.AddItem "benny"
Combo1.AddItem "bagley"
End Sub
Now, when the program is run, the names should AutoComplete... sort of.
Try this and let me know if it's what you're after.
If not, more details please.
Set the combox.style=0 ' DropDown Combo. Then as you type, into the text portion, the combo box will be positioned to the show the 1st matching item BUT if at any time all the characters that you typed do not match the beginning of an entry, the combobox will be positioned at the 1st entry.
I'm sure there is something on this on the Microsoft site. If not, there is a thread down below, I believe it was nonguru's thread that explains how to populate a combo box, did you check that out?
Hey there thanks for the input. Still not what I really want. At random I will add a name and I want it to add to the combo box where my list is. If this helps you.
Thanks for your time.
Margaret ;-)
Ok Margaret, I am determined to solve your problem now
However, I need a better understanding of what you are doing, so please give me as much detail as you can.
From what you've told me so far, all I know is that you have a form with a combo box. Does the combo start with no members? What else is on your form? What else happens in your program? You said earlier ...
At random I will add a name and I want it to add to the combo box where my list is
Questions - 1.Do you mean you will enter the name from the keyboard, using a text box or something, or maybe an input box?
2.What do you mean by "at random"?
3.When you say "combo box where my list is" - is this just a list of names that you have entered?
Please remember that no one knows any of the stuff about your program that you know. You have to explain well enough for us to know what you want to do.
Remember, you can not give too much explanation.
Cool. Hope I can help you, since I'm really interested now.
Just another question/statement,
I'm not sure what you want when you are talking about
auto completion for the combo box.
Could you state, step by step, what you want to happen
in your program - i.e. what the user will do, and how the program should respond.
thanks. >:O>
Well I am using a databar that is connected to my Access database. That is my list. I want the combo box which is used for last names to autocomplete last names and to be able to update the infromation from the combo box. That is when I add new last names. Is this all you need. If not please give me your e-mail address and will send you demo of what I am doing. Thanks for your help.
Margaret
;-)
Hey Margaret, this is the first time you mentioned that
you were using Access!
You have to provide a good description of your problem
if you want a good answer.
Now, this is what I think you want to do...
tell me if I'm right or wrong please
You have an access database, and one of the fields
is "Last name". You want to be able to select a
"last name" from a combo box and have the other
fields for that record automatically display on your form"
1. Is this correct? Is this what you want to happen?
2. How do you want to display the other fields? e.g. Text Box?
Ok, let me know if I've got it right.
maybe you could send me a copy of the code too. amihappy@hotmail.com
Margaret, disregard my last email.
I think I understand you now.
It helped a lot when you mentioned that
you were using Access.
I have been fiddling around with the data control
(which you are calling data bar?)
I found it pretty straight forward to get a combo
linked to an access data base.
If you are having trouble, check these things.
1. You have set the database name correctly.
2. You have set the database recordsource property.
3. You have set the combo data source to the name
of your data control e.g. Data1
4. You have set the combo data field property.
5. The combo style is set to 0 (zero)- Dropdown Combo
6. Double check that you have all the things above
spelled correctly.
Are you setting the database name, recordsource etc
at runtime, or at design time?
If you are setting them at design time, it should be simple,
since you can select them from the dropdown list,
but if you are setting them at runtime, be very careful
that you spell everything correctly and get the database
name path correct.
Let me know how you go. I think I am finally with you now.
LOL :-D
Well everything you have mention up above I have already done. I know that there is a code to do the autocomplete for the combobox that I am using for the Last name. This is the only box that I will be using it for. The rest of the boxes are Text boxes. Sorry about not able to explain it better. I am still new at all this. I have a book but doesn't do me any good about difficult things like the combo box. Thanks for your time I will send you a copy of what I am doing.
Hi,
Will you try this code please.
Say you have a database called myDB and a recordset Names where the field you want is Lastname.
You can use the code I putted in the form load event in the click event of a command button if you want to refresh your combobox.
******************************************
Private myConn As New ADODB.Connection
Private myRS As New ADODB.Recordset
Private myIndex As Integer
Private Sub Form_Load()
myConn .Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Database\myDB.mdb"
myRS.Open "SELECT LastName From Names",myConn, adOpenStatic, adLockPessimistic
myRS.Requery
With myRS
Do Until .EOF
Combo1.AddItem !Lastname
.MoveNext
Loop
End With
myRS.Close
Verbinding.Close
End Sub
Well Imhoteb didn't work but this is my code. See what I might have to change. So far everything works but the auto complete.
Thanks
Option Explicit
Private sDataPath As String
Private Sub CboLastName_Click(Index As Integer)
Select Case Index
Case 0
Data2.Recordset.FindFirst "[Last Name]='" & CboLastName(Index).Text & "'"
End Select
End Sub
Private Sub Command1_Click()
End
End Sub
Private Sub Command2_Click()
Shell ("Calc.exe", 3
End Sub
Private Sub Command3_Click(Index As Integer)
Data2.Recordset.AddNew
End Sub
Private Sub Command4_Click()
Data2.Recordset.Delete
Data2.Recordset.MovePrevious
End Sub
Private Sub Command5_Click()
PrintForm
End Sub
Private Sub Form_Activate()
Dim X As Long
Data2.Recordset.MoveFirst
For X = 0 To 0
CboLastName(X).Text = Data2.Recordset("[Last Name]"
Next
Do
For X = 0 To 0
CboLastName(X).AddItem Data2.Recordset("[Last Name]"
Next
Data2.Recordset.MoveNext
Loop Until Data2.Recordset.EOF
Data2.Recordset.MoveFirst
End Sub
Private Sub Form_Load()
sDataPath = App.Path & "\Children3.mdb"
Data2.DatabaseName = sDataPath
End Sub
;-)
Hi again Margaret.
We are going in circles a bit :-(,
so before going any further, I would appreciate if you
could give a very detailed explanation of what you
want this program to do.
Could you answer all these questions.
1 List all the objects on your form - their type and name
2 What you want to happen when the program starts
i.e. what is to happen in form_load event
What variables are set etc.
3 What you want the user to be able to do.
e.g. "I want them to be able to click on
combo box and this happens:"
e.g. "When they click on command1 I want
this to be displayed."
(please be very descriptive)
4. Are you using combo box, dbcombo or datacombo control?
If you answer all these questions and give a detailed description of what you want the program to do, I think
we can get it working. ;-)
I am using the Combo box. Not the data one. I have the code for it. I have about 25 text boxes and using the combo box I have it to display the information in the text boxes. This works. I just want it to update the combo box which it only does after I exit it out. Everthing else does when I hit the update button I have placed on the form. The auto complete does not work at all for I am missing the code for it and can not find a code for it at all. So lets just get one thing working I guess at a time. My code is listed but not the update just got that working last night. I will add it to it.
Option Explicit
Private sDataPath As String
Private Sub CboLastName_Click(Index As Integer)
Select Case Index
Case 0
Data2.Recordset.FindFirst "[Last Name]='" & CboLastName(Index).Text & "'"
End Select End Sub
Private Sub Command1_Click()
End End Sub
Private Sub Command2_Click()
Shell ("Calc.exe", 3 End Sub
Private Sub Command3_Click(Index As Integer)
Data2.Recordset.AddNew End Sub
Private Sub Command4_Click()
Data2.Recordset.Delete
Data2.Recordset.MovePrevious End Sub
Private Sub Command5_Click()
PrintForm End Sub
Private Sub Command7_Click()
Data2.Recordset.Update End Sub
Private Sub Form_Activate()
Dim X As Long
Data2.Recordset.MoveFirst
For X = 0 To 0
CboLastName(X).Text = Data2.Recordset("[Last Name]"
Next
Do
For X = 0 To 0
CboLastName(X).AddItem Data2.Recordset("[Last Name]"
Next
Data2.Recordset.MoveNext
Loop Until Data2.Recordset.EOF
Data2.Recordset.MoveFirst End Sub
Private Sub Form_Load()
sDataPath = App.Path & "\Children3.mdb"
Data2.DatabaseName = sDataPath End Sub
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.