Auto Population Of A Combo-Box?
Is there a way to Populate a Combo Box through the actual Source-Code?
*Feels really stupid. :*
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Combo Box Population
I want to populate a combo box using the result of a query. The code below is waht I have so far but it keeps on giving me a type mismatch error and I dont know why. Please help
Private Function PopulateCombo(MyCombo As ComboBox) Dim lnMyConn As Integer Dim sqlText As String Dim lsMsg As String Dim lsType As Double Dim lnPos As Integer MyCombo.Clear' lsType = 8 sqlText = "SELECT Description, Code FROM ParameterMaster WHERE Type = 8 ORDER BY Description" lnMyConn = ConnectSql glResult = SqlSendCmd(glSqlConn(lnMyConn), sqlText) If (glResult = SUCCEED) Then Do Until SqlNextRow(glSqlConn(lnMyConn)) = NOMOREROWS' MyCombo.AddItem Trim(SqlData(glSqlConn(lnMyConn), 1)) & Space$(50) & Trim(SqlData(glSqlConn(lnMyConn), 2)) MyCombo.AddItem Trim(SqlData(glSqlConn(lnMyConn), 1)) Loop Else lsMsg = "Sql Error, Unable to Retreive Combo Information." MsgBox lsMsg, 48, "Warning" Disconnect lnMyConn Exit Function End If Disconnect lnMyConn End Function
This is how I call my functionon form load
Private Sub Form_Load() PopulateCombo (cmbTitle) End Sub
Combo Box Population
this has probably been answered before but, I have a combo box on a form with the zipcode it is populates by a zicode field on a table I want the textbox for the city and state to update based off the zipcode selection. the for is also bound to the database
Combo Box Population
I am trying to populate a dropdown combo box with a recordset. Generally, you populate the combo box with only one field of information though. How can I automatically populate the combo box with more than one field (Below is what I'd like the box to look like when dropped down)?
Bob Smith 1235 Dept. 1
John Doe 2345 Dept. 2
Jane Doe 3556 Dept. 5
Combo Box Population From Array And Loop
What is happening is that 5 combobox items are being populated with nothing instead of the the string information that I am trying to get into the combo box from the array with a loop.
'fill index from array to combobox.
names = Array(apple, frog, prince, duckling, swan)
For i = 0 To 4
newitem = names(i)
'string then index for combo item
List Type Combo Box Population
I've got a function that populates a form from database records. On this form are several dropdown list comboboxes so the user can't type anything into them at data entry. When I fill this form, if there's no data in one of the combo box fields, I get an error that the text property is read only. I'm basically setting the combo box text to "" if there's no data. What's a work around for this error - I'm tempted to use resume next but don't really want to do that.
Automatic Population Of Combo And Text Boxes
I have created an input form(inpform) in access using VBA and I need to automatically populate other boxes on the form (from a separate table) when the contents of one box is entered.
The documendet table contains the following fields:-
When the filename is selected from the filename combo box on the input form (inpform) this should automatically populate the system combo box with the system used, the Menu combo box with menu the document is on, the document name text box with name of the document and the document description text box with details of what the letter is for. All this information is held in the documendet table.
When filename "BIRTHDAY" is selected from the filename combo box on the input form this should automatically populate the system combo box with "WORD", the Menu combo box with "LETTERS", the document name text box with "HAPPY BIRTHDAY LETTER" and the document description text box with "A LETTER TO WISH THE CUSTOMER HAPPY BIRTHDAY".
Being new to VBA I'm not even sure where to start with this so any help would be greatly appreciated.
Edited by - julesl on 10/6/2003 12:58:26 AM
Combo Box Auto Search
I got a combo box and it is linked to a table full of employee's details. what i need it to do is when i scroll the list and find the employee and click on it, display the information about him within the form.
Newbie question, but i am a newbie tbh
Any help is most welcome
Combo Box Auto Drop
I am a newbie at this so please be patient. I have a combo box that gets populated with names of customers from the CUSTOMER table from an access database. What I want the user to be able to do is that when they type a last name in that combo box, the combo box automatically drops open and start scrolling to the matching last name. So far I have a List box performing this action and its working like a charm. But my client wants a combo box to save some space in stead of a list box.
I have tried posting this question in Microsoft Knowledge Newsgroups and received an answer. The person gave me a link to a website that allowed me to download a VB project that does exactly what I need to do. But the code in that project is extremely complex. Being a Newbie that I am, I have no idea how to decipher it. Can anyone give me a better solution to my problem? I'd much appreciate it.
Combo Box Auto Fill
I'm surprised i couldnt find the answer to this in the forum. Maybe i'm searching wrong..
But I'd like to know what I need to do to get a combo box to automatically fill in as you press keys.. such as
If i have a combo box with AM and PM in it, if i press A, I want it to go to AM if I press P, it brings in PM for me..
Is there a property to set I'm overlooking? i know it's got to be a really simple thing, but I can't seem to find it.
Combo Auto Search
when i type "T" in combo box, the word "Three will be display and the "hree" is highlited?
how can i do that?
Combo Box Auto-expanding
I have a combo box that is loaded with a list of values
Certain values are lengthy that am not able to see them.
How should i make my combo box auto-expand its width to see contents..
Combo Box Auto Complete
i have combo box with multiple values , i want when i enter one character to complete automaticaly the nearest available entry and if i type one more character it will match the next and so on
Combo Box Auto List
How do i list whatever was in the combox without clicking on the small arrow?
I want when the user lunches the program , the drop list to be already opened?
Combo Box Auto Display
Example: in the combo box I have listed the following:
Now , when I type (1) in the combo text box , and press enter , I want the list to automatically search for that id and display it.
I don't want to use any kind of loop because I think the combo box can do it automatically! Try this , type number 1 in the combo text box and click on the list arraw and it will go directly to the item which starts with number 1.
Auto Complete Combo Box
Can anyone tell me a code of Auto Completing the combo box list. I mean as soon as user start typing in the combo box, it shoud bring the releted item.
Thanks in advance
Auto-completing Combo Box
I found this function somewhere a while ago;
Stick this in a module;
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const CB_FINDSTRING = &H14C
Const CB_ERR = (-1)
Public Function AutoFind(ByRef cboCurrent As ComboBox, ByVal KeyAscii As Integer, Optional ByVal LimitToList As Boolean = False)
Dim lCB As Long
Dim sFindString As String
On Error GoTo Err_Handler
If KeyAscii = 8 Then
If cboCurrent.SelStart <= 1 Then
cboCurrent = ""
AutoFind = 0
If cboCurrent.SelLength = 0 Then
sFindString = UCase(Left(cboCurrent, Len(cboCurrent) - 1))
sFindString = Left$(cboCurrent.Text, cboCurrent.SelStart - 1)
ElseIf KeyAscii < 32 Or KeyAscii > 127 Then
If cboCurrent.SelLength = 0 Then
sFindString = UCase(cboCurrent.Text & Chr$(KeyAscii))
sFindString = Left$(cboCurrent.Text, cboCurrent.SelStart) & Chr$(KeyAscii)
lCB = SendMessage(cboCurrent.hwnd, CB_FINDSTRING, -1, ByVal sFindString)
If lCB <> CB_ERR Then
cboCurrent.ListIndex = lCB
cboCurrent.SelStart = Len(sFindString)
cboCurrent.SelLength = Len(cboCurrent.Text) - cboCurrent.SelStart
AutoFind = 0
If LimitToList = True Then
AutoFind = 0
AutoFind = KeyAscii
Then, in the KeyPress event of the combobox in question - do this
Private Sub cboText_KeyPress(KeyAscii As Integer)
KeyAscii = AutoFind(cboText, KeyAscii, False)
Auto Complete Combo Box
At present this is what's happening. In VB6, i have a Databound combobox link to a SQL2000
database using Data Environment Object. When i clicked on the dataCombobox
and start typing in a character it should automatically complete theword
based on the data found in the DataCombo (same function for AutoExpandin access). For instance, i have 5 data "Jon,
Tom, Time, Mary, Jane" in the data. If i type "to" in the datacombo it
should automatically find the closest match (which it Tom, in this case)and
display it in the dataCombo.
Does anyone know there is a way to do it?
Thanks in advance.
Combo Box Auto Select
I don't know if this is possible but here it goes. I have a combo box that I populate with a stored procedure. Here is the code. I would like to be able to auto select(as the user types in the box it finds the name ) but if I do so I can't get the list index of the item. I have to really click the selection to get the corresponding List Index. How would I get this to work?
Set rsPopulateRequestor = New ADODB.Recordset
rsPopulateRequestor.Open "spRequestorPopulate", Cn, adOpenForwardOnly
Do Until rsPopulateRequestor.EOF
cboRequestor.AddItem rsPopulateRequestor!LastName & ", " & rsPopulateRequestor!FirstName
cboRequestor.ItemData(cboRequestor.NewIndex) = rsPopulateRequestor!RequestorID
Thanks in advance
Help With Combo Box And Auto Date In TextBox.
Kind of new to VB. Learning as I go along here. Is there a way to have a textbox automatically enter in that day's date when opening that file?
Also I put some code in for a combo box in word. I used the control toolbox to place the combo box and then just added the items.
Private Sub Form_Load()
That works fine when I run it but when I save and close the file and get back into it, the code is there but everything in the dropdown list is gone. Basically I want to create a template that others can use. Once they open up the file everything should up and running. Is there a way to design this and not use code? Am I just doing something wrong with the properties? Or is there another way to do it and keep the functionality saved. I remember with Outlook it had more of a properties menu feature that allowed me to do that without VB Code. I just started using Word for some VB and getting lost here.
Any help would be appreciated.
Generating Auto Items For A Combo Box
I have 2 comboboxes on a form. One combobox has "Master Room Suits" and "Standard Room" as its items. Now what I need to do is when the user selects master room suite, the second combobox creates items labelled 1 to 5 . and standard room as 1 to 8. Does n e 1 know how to do this????
Auto Complete Data Combo
I was wondering if anyone knows how I can get the Data Combo control to do type ahead. It kind of does it now, but instead of displaying what the user is typing and highlighting the matched entry it highlights the whole word. It also looses what the user types after a few seconds. This makes it hard to use. I need to use the data combo, because I am binding it to an ADO recordset. I figured out how to get this functionality to work on a regular combo using the API, but I can't bind the regular one to a recordset. I am open to buying a third party control if anyone knows of one that will serve my needs.
Auto Display Text In Combo Box
OK, I would like to have a combo box containing all the states. When the user starts to type, it will pull up the closest state that matches the text he is typing in.
User hits "M" and the first state listed with "M" would be displayed "Maine". User Continues to type "MAS" and Massachusetts" would be displayed next. User Types "MASA" and nothing is displayed I think you get the idea, Right? LOL
So how can I do this? Is there an easy or standard way this is done?
Thanks for reading this.
Combo Box Auto Selection Of Item At Start
I have a combo box that is set to dropdown list(so read only) and a couple of records in it. Now the problem is that when i start the program there is no field selected in the combo box and i need to select a filed by hand, but i want the first field to be selected at start(or could be any other field)
How do i do this?
Auto-complete Feature In VB Combo Boxes
In access, when making forms, you can add combos boxes.
then if you type in the combo box, it automatically completes what you ar typing.
eg, if there is a value 'forest' in the combo box, as you type 'f' the word forest will appear. you can then enter or tab out of the combo box to accept that value. otherwise, you can keep typing over it.
anyone know how to replicate this in VB?
Populate Combo Box && Auto Complete For US States
Should you put the code in the program to populate a combo box or should you have it reference a table or do it another way?
For example lets say you have a combo box that is going to list the abbreviations for all the states in the U.S. Do you .AddItem for each 50 state abbreviation? Or should you just write them in a small table and have the program reference the table to fill the combo box?
I'm just curious as to which would be better so as not to slow my program. Or, if there is another option that would be helpful as well.
Auto Combo Box Creation In MS Word Tables
I have a project on that requires automating the creation of combo boxes in the third column of
each and every row in all tables within an MS Word 2000 document.
While each combo box bookmark is to be uniquely named within the code (using something along the lines of Status"&xVal, the values of the combo list are the same 6 or 7 text stringsin the document.
Not being a VBA expert, any help here will be greatly welcomed.
Combo Box Auto Complete (and The Ability To Correct Typos)
I am using the code by Comintern in the following link to auto complete a combo box
The code works beautifully except that if I type the letter J instead of K it will not allow me to backspace. Anybody have any ideas how to fix this.
I really have not had a change to figure something out yet.
Auto Complete Text Box Or Combo Box In Visual Basic 6
Some boddy do good for me
d brings up Doctor Dave and looks like this Doctor Dave with the current cursor position on "o", now when the next letter o
is entered you would still get the almost the same thing except that highlight would now start on the "c", then by press the letter n, it would now show Don Newbie with the highlight and current sursor position on the space.
Windows XP Messenger it best example of this.
Same Thing in working In Internet Explorer, here is a Example enclosed
Edited by - Venoms on 3/18/2003 3:08:13 AM
Combo Box (extended Matching) Auto Select Not Functioning. **RESOLVED**
OK going nuts here, I know this should work, did alot of digging around here and came up with all these solutions of how to get a combo box to auto complete or search text. IE
Entries in combo box:
the user pressed B and it selects Billy since its the first B, then the user presses o and it moves down to bob in the list etc..
Well from all the digging i do, these next two examples of code should work.
'DeclarationsPrivate Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As LongConst CB_ERR = (-1)Const CB_FINDSTRING = &H14C Private Sub Combo1_KeyPress(KeyAscii As Integer) Dim CB As Long Dim FindString As String If KeyAscii < 32 Or KeyAscii > 127 Then Exit Sub If Combo1.SelLength = 0 Then FindString = Combo1.Text & Chr$(KeyAscii) Else FindString = Left$(Combo1.Text, Combo1.SelStart) & Chr$(KeyAscii) End If CB = SendMessage(Combo1.hWnd, CB_FINDSTRING, -1, ByVal FindString) If CB <> CB_ERR Then Combo1.ListIndex = CB Combo1.SelStart = Len(FindString) Combo1.SelLength = Len(Combo1.Text) - Combo1.SelStart End If KeyAscii = 0End Sub
'In keypress of combobox KeyAscii = AUTOFIND(Me.Activecontrol, KeyAscii, True) ' The Decalarations Private Declare Function SendMessage Lib "user32" Alias _ "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _ ByVal wParam As Long, lParam As Any) As Long Const CB_FINDSTRING = &H14CConst CB_ERR = (-1) ' The Function '*******************************************************************************' AUTOFIND (FUNCTION)'' DESCRIPTION:' AUTOCOMPLETE A COMBOBOX (WORKS !!!)'******************************************************************************* Public Function AUTOFIND(ByRef cboCurrent As ComboBox, _ ByVal KeyAscii As Integer, Optional ByVal LimitToList As Boolean = False) Dim lCB As Long Dim sFindString As String If KeyAscii = 8 Then If cboCurrent.SelStart <= 1 Then cboCurrent = "" AUTOFIND = 0 Exit Function End If If cboCurrent.SelLength = 0 Then sFindString = UCase(Left(cboCurrent, Len(cboCurrent) - 1)) Else sFindString = Left$(cboCurrent.Text, cboCurrent.SelStart - 1) End If ElseIf KeyAscii < 32 Or KeyAscii > 127 Then Exit Function Else If cboCurrent.SelLength = 0 Then sFindString = UCase(cboCurrent.Text & Chr$(KeyAscii)) Else sFindString = Left$(cboCurrent.Text, cboCurrent.SelStart) & Chr$(KeyAscii) End If End If lCB = SendMessage(cboCurrent.hwnd, CB_FINDSTRING, -1, ByVal sFindString) If lCB <> CB_ERR Then cboCurrent.ListIndex = lCB cboCurrent.SelStart = Len(sFindString) cboCurrent.SelLength = Len(cboCurrent.Text) - cboCurrent.SelStart AUTOFIND = 0 Else If LimitToList = True Then AUTOFIND = 0 Else AUTOFIND = KeyAscii End If End If End Function
However. when i run this I get errors on the .SelLength. The exact error is.
Run time Error 380:
Invalid property value
Anyone have any idea why?
Do i need any references etc. setup?
VB's auto code recognition stuff sees that as an option, IE when i type combo1. the drop down list after the period shows SelLength as an option.
Pulling my hair out here, anyone have any ideas?
Thanks in advance for any assistance you can provide.
PS: yes i changed all the combo1's to the name of my combo box
similar to what shofstetter wants, i was wondering how do i open a textfile, and take its contents and place them into my textbox?
I want to make an xml at runtime , the data of the xml comes from an access database
I have a db xyz and a table steps
design of table steps in db xyz
where the parent id represent the parent of the step which is anothere step in the same table
And my xml structure is :
<NODE text ="[stepname]" Sectionid="[stepid]">
<NODE text ="[stepname]" Sectionid="[stepid]">
the xml output for the eg data would look like
<NODE Text="anc" Sectionid="111">
<NODE Text="abc" Sectionid="123"></NODE>
Can somebody help me in this
I am using vb6 and mxml parser 3
Hi, I have a text file and a listbox
the contents of the text file are url's, (one on each line)
How can i retrieve each line from the file and then use .additem to add the url's to my listbox one by one?
Drop Down Box Population
I have a simple ado database form that has combo boxes populated from another database. I want to be able to select fields from the drop down box and save it to the database for the form not the drop down database. When I hit update then next without selecting from that populated drop down box, no errors occur and the database is updated properly. When I select from the populated drop down box, hit update then next, i get the following error: "Data error event hit err: Operation was canceled"
here is the code for the drop down box population:
Dim rs As ADODB.Recordset
Dim Con As ADODB.Connection
Dim ssql As String
Const strCon = "DSN=jdepd;Description=jdepd;UID=nada;Password=pass;"
Private Sub Form_Load()
Set Con = New ADODB.Connection
Set rs = New ADODB.Recordset
'sql statement to select items on the drop down list
ssql = "Select PUOMWPRJID From f98221"
rs.Open ssql, Con
Do Until rs.EOF
'Close connection and the recordset
Set rs = Nothing
Set Con = Nothing
List Box Population
I am trying to populate my list box with whatever files that are contained in a particular folder. Can anyone help. I am trying this but I get the obvious. Please Help.
a = 1
Do Until a = TotalRooms
FileName = (App.Path + "
oom" & (a) & "final")
a = a + 1
Thanx in advance.
cant seem to make this work properly. I'm making this treeview that reads data from and SQL server. Sometimes it gives me half a list and sometimes nothing or just 1 item.
Do Until .EOF
Set Node1 = TreeView1.Nodes.Add(, tvwFirst, "I" & .Fields("functionID"), .Fields("functionName"), 1)
Do Until .EOF
Set Node2 = TreeView1.Nodes.Add("I" & .Fields("functionID"), tvwChild, "K" & .Fields("typeID"), .Fields("typeName"), 2)
Do Until .EOF
Set Node3 = TreeView1.Nodes.Add("K" & .Fields("typeID"), tvwChild, "H" & .Fields("valueID"), .Fields("valueName"), 3)
'Node1.Expanded = True
My table in the database looks like this:
functionID, functionName, typeID, typeName, valueID, valueName
As you can see all the ID's can have the same numbers, and i think thats where the problem lies. How can i solve this issue in my code? Adding a number per key?
im populating a listview with over 2800 users. but there is a problem, or rather an annoyance, it takes an hour using the method im currently using. i wondered how i could speed this up. im currently using the NetUserEnum API, and wondered if this in fact the best one to use for this task
I have a form with some text fileds and a MSHFLEXGRID. Both are connected with same datasouce and member. My intension is to view the data in the grid when a record is added.
What is the easiest way to do this?
I have this procedure that suppose to populate a datagrid but it does, the database is Access and I runing VB 6.0 ADO method. My little estatements does work at all. If anybody know the best way to do it you can tell me what is wrong on it. I really tired to read tutorials but the tutorials never shows you what you want to do. Here is my litte statements
rsd.Open "SELECT * FROM ProjProd", cn, adOpenKeyset, adLockOptimistic
Set DataGrid1.DataSource = rsd
This does not populate nothing, in another words the record set soes not have concetion to Datagrid. I am asking you if do you know a better method. I am not use the data control because it is only VB code.
Thank you for your respeonse.
Ok, the following code, in theory should work... but in fact it doesn't what is wrong ?
Private Sub Command1_Click()CD.Filter = "Text Files (*.txt)|*.txt"Dim strData As StringDim astrDataItem() As StringOn Error Resume Next'Open text file and split by :'s CD.ShowOpen If CD.FileName = "" Then Else: Open CD.FileName For Input As #1 Do Until EOF(1) Line Input #1, strData astrDataItem = Split(strData, ":") ListView1.ListItems.Add 1, , astrDataItem(0) ListView1.ListItems.Add 2, , astrDataItem(1) Loop Close #1End IfEnd Sub
CD = CommonDialog control
Any Help would be greatly appreciated,
Hi - I'm pretty new to this stuff, but I'm having a blast. I need to populate my combobox #1 with a simple list from an Excel file, then based on the combobox #1 selected item combobox #2 populates with another Excel list. Am I kidding myself? I've seen great stuff in here but I'm just not "there" yet... VB 6.0 Professional
I am trying to create a Hierarchical view of my data. I was wondering how to set the records to the child or the parent as the recordset roll thru. I am using a coded ADO recordset with no binding. All of the examples I have found are all databound related. I also understand the fundamentals of the FlexGrid control, just not how to set the parent/child part of a HFlexGrid Control. It looks like I use bands, but I have not found any examples to create them.
I have a listview control on one of my forms... I am trying to populate the listview so that I have a users username in one colum of my listview, and the users fullname in the next column on the same row. I then want to be able to select the entire row (username and lastname together) to proceed with the function... I have entered the following code to a listview with the view properties of list, fullrow select, and multiple columns:
frmFIND.lstvwResults.ListItems.Add , , rsMyRS!UserNamefrmFIND.lstvwResults.ListItems.Add , , rsMyRS!EMPLOYEE_NAME
This results in a display on the listview of 2 records showing:
why is this happening like this? What do I need to do to fix this?
Elegant Cbo Population
So if we're agreed that data-bound controls are evil (and I do believe they are now), what is the most elegant/fastest/easiest way to populate a combobox w/ a list of items and their associated IDs?
To use a simple example,
"SELECT tblProject.ProjectName, tblProjectID FROM tblProject"
gives me the two things I need. ProjectName gives me the items I want to populate the cbo with so my users have something readable, and ProjectID gives me the key value to do my thing behind the scenes.
Populating the combox w/ ProjectName is obviously easy as I just loop through the recordset.
The crux of the matter is how do I keep track of the associated ID when they click on an item in the combobox?
Disconnected recordset? Array?
If this influences the answer at all, we're talking about ~100 records or so. And yes, they all need to be available to the user.
Help With MSFlexgrid Population!!!
I am about to pull my hair out on this one!
I am trying to populate a msflexgrid with a recordset.
When I try to use the textmatrix function I keep getting a subscript out of range error. I cannot figure it out.
Can someone please post a few lines of code on how to do this...would be greatly appreciated!
After populating a combo box with font names - and sorting alphabetically. How tdo I get the bold, italic, underline buttons to respond to the first font in the list? e.g. the first alphabetical font on my system is a bold and I want the bold button to become pressed after populating etc for italic and underline if it applies to the font. This will differ for each system.
ADO & BDCombo Population
I just want to populate an ADO DBCombo box using the "Data Environment Designer". This allows me to make a connection to may access database and create a command querry.
Whenever I use this it only takes the 1st field from my database. I want it to add the whole column. Any ideas how I can make this add the entire Column to the DBCombo box? This is about 50 entries (the states for the U.S.) and I just wanted it in my DBCombo box.
Any help appreciated.
Timothy H. Schilbach
Alpha Omega Design Inc.