Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Select An Item From A Combo Box And Show A Field In A Text Box


How can I display a field in a text box by selecting this field from a combo box. More simply, I have a DB MSACCESS in this db I have a table in this table I have two fields. One field I populate in a combo box, but the second I need to display in a text box. Any time when I select any data from combo box I need to show the second field in a text box. I have this code

Dim dbs as Database
dim rs as RecordSet

Set dbs = Opendatabase("Products")
Set rs = dbs.OpenRecordset("ProdCode", dbOpenDynaset)

Do until rs.EOF
Combo1.AddItem Format (rs!StockNo)
text1 = rs!Product
rs.MoveNext
loop

The code populate de combo, but when I select an Item from the combo doesn't show me the data in the text box. Thank you for your help and support.

Manny




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Getting Combo Box To Show -Please Select- Text
I am adding a ComboBox to a worksheet, purely in a list format with several available choices. However the default view is none of these choices show immediately - the box is blank until you hit the drop down arrow. Does anyone know how I can enter the text --Please Select Data Type--- to show in the box at the beginning ?
thx
Mark

Getting Combo Box To Show -Please Select- Text
I am adding a ComboBox to a worksheet, purely in a list format with several available choices. However the default view is none of these choices show immediately - the box is blank until you hit the drop down arrow. Does anyone know how I can enter the text --Please Select Data Type--- to show in the box at the beginning ?
thx
Mark

Click Item In Listview Then Show That Item In Combo As Index = 0
Hi guys,

I have a listview (lvwUserPunchedOut) that is populated with records in a database (persons first name in one column and last name in the second column), what I am looking to do is if I select a persons name by clicking on it in the listview on frmMain, and then bring up frmSearchCriteria, i would like to show that selected name in the combobox as default (cboEmployee.ListIndex = 0) on frmSearchCriteria (the combobox is sorted = True and is also populated with first name and last name of the person)

How would this be done? Hope I make sense. Thanks in advance.

Combo Item Select
VB Code:
Private Sub Combo1_Change()    MsgBox Combo1.TextEnd Sub


how come that doesnt msgbox anything when i select an item from the combo box?

Also, When I Select An Item In A Combo Box ...
... I want to be able to press an `OK` button what I also created and be able to access the page that is selected in the combo box.

I can`t find out how to do this because I just enter the combo names in the `List` property.

Any help on this one. Thanks.

Solved:for The Wizard Geof - Select From Item And Show Data Filtred...
In effect i want to scroll into userform the value from columns of the shseet(all tbox are identified with col_x where x is the letter of column), but:
1) Insert only unique value in combobox1 from column D ( naturally without blank cells)
2) if i select from cbox1 a value for example EXUV, permit the scroll (with scrollbar1) of value in variuos tboxes only if line is identified with EXUV...






Edited by - luca91 on 1/18/2007 3:02:14 AM

Select An Item In Combo Box Upon Load
Hi all,

I have a simple question. I have a VB6 program with at least 2 forms. The first form which interest us is used by a user to select the department in which he works. The second form receive that information plus the list of ALL departments.

What I want to acheive is this :

- The first form is opened.
- The user selects a departement from a combo box.
- The user clicks ok.
- The second form receive the information of the first form in a variable.
- Another combo box is present on the second form and is already filled with all the department names (identical to the one in the first form combo box).
- On load, the departement from the first form is selected in the combo box on the second form.

Is that clear enough to understand?

Automatic Select Item In The Combo Box
Whut i want to do here is i want the combo box select the specific item when the form load. But i do not know whut's the code beside .additem..Anyone help me




Code:


If Not IsNull(myRecSet![Rec]) Then .cmbRecName.Additem myRecSet![Rec]

Select An Item In A Combo Box (Urgent)
Can any body tell me how to select an item in a combo box when we typing on it.?
Or
Can we drop down the combo when we typing on it?

should I search the list and filter the records

Select Item In Combo Box From Itemdata
hi, I have the value of Itemdata and want to select the combobox.

I do not want to run the loop.

If I have the value of the item then I use SendMessage and CB_FINDSTRING...How do I do it with ItemData?

How Do I Select An Item From A Combo Box With A Mouse
This is an old one I know but I am stumped again!
I have a simple combo box with a list of 20 items I have added with additem.
I want to simply pick one of these with a mouse and put its value (Combo1.text) in another procedure (like you can do in Access).
None of the subs associated with the combo box seem to fire when you do this. The nearest being _Change when you type something in the box but picking from the list doesn't represent a change.
The last time I used a combo box this way was with Windows98 and before SP6 and I though it did then???
 

Problem Save Combo Box Select Item To ADO
hello,how to save combo box select item to ado database?i have problem when select combox box item,item selected from combox box didn't save to the Ado database


VB Code:
Private Sub DataGrid1_Click()DataGrid1.SetFocusDataGrid1.MarqueeStyle = dbgHighlightRowDTPpurchase.Value = DataGrid1.Columns(1)DTPScrap.Value = DataGrid1.Columns(7)Txtitem2.Text = DataGrid1.Columns(4)Txtidnumber.Text = DataGrid1.Columns(4)Txtprice.Text = DataGrid1.Columns(5)Combo1.Text = DataGrid1.Columns(6)DataGrid1.RefreshEnd Sub Private Sub Form_Load()Dim rsLookup As ADODB.RecordsetOn Error GoTo ErrorHandlerDim path As Stringpath = App.path & "Tool.mdb"  cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.path & "Tool.mdb" cn.CursorLocation = adUseClient Debug.Print "Connection Object Created" rs.Open "SELECT * FROM Inventory ", cn, adOpenStatic, adLockOptimistic Set DataGrid1.DataSource = rs Debug.Print "Connection Object Created"   'status list Combo1.AddItem "Active" Combo1.AddItem "Relocate" Combo1.AddItem "Spoilt"   'Open the lookup recordset Set rs1Lookup = New ADODB.Recordset rs1Lookup.Open "SELECT distinct Location From Inventory", cn, adOpenStatic, adLockReadOnly  'Hook the data combo control to both the 'data recordset AND the lookup recordset! If rs.RecordCount > 0 Then   With DataCombo1 '---> SET AT DESIGN TIME. <--- '.Style = dbcDropdownList 'The data recordset Set .DataSource = rs Set .RowSource = rs1Lookup .BoundColumn = "Location" .DataField = "Location" .ListField = "Location"  rs.MoveFirst  End With End If Set DataGrid1.DataSource = rs Text1.Text = "Database Record " & "_" & rs.RecordCount  Exit Sub exit_Sub: Set rs = Nothing Set cn = Nothing Exit SuberrorHandler: MsgBox "ERROR! Err# " & Err.Number & " Desc: " & Err.Description, vbCritical + vbOKOnly Resume exit_Sub End Sub Private Sub cmdSave_Click() With rs .Fields("Location") = Txtlocation.Text .Fields("Date Of Purchase") = Txtdateofpurchase.Text .Fields("Item Description 1") = Txtitem1.Text .Fields("Item Description 2") = Txtitem2.Text .Fields("ID Number") = Txtidnumber.Text .Fields("Price") = Txtprice.Text .Fields("Status") = Combo1.Text .Fields("Date Of Scrap") = Txtdateofscrap.Text .Update End If End Withend sub


please help!

How Do I Get A Field In Acess Database To Show As List In Combo Box ?
at form load, I have code like below


Code:
Private Sub Form_Load()
Dim sql As String
Dim i As Integer

StrConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "master.mdb;Persist Security Info=False"
    With Cn
        If .State = adStateOpen Then .Close
        .ConnectionString = StrConn
        .ConnectionTimeout = 90
        .CursorLocation = adUseClient
        .Open
    End With

sql = "SELECT * FROM Room"
Rs.Open sql, Cn, adOpenDynamic, adLockOptimistic, adCmdText
cboCustomerID.Clear
For i = 1 To Rs.EOF
cboCustomerID.AddItem !rs.("customerid")
Next
' With Rs
' Do Until .EOF
' cboCustomerID.AddItem !roomid
' .MoveNext
' Loop
' End With

Call DisplayData
End Sub


This code is unusable because it can't show me the list of customerid from access database. I use adodb and jet database 4.0 as a provider.

For displaydata sub routine have only...

txtroomid = rs("roomid")
...

Anybody please help me.

Access Select Qry - Join Number Field To Text Field
Hey

I have a select query with 2 tables which I want to inner join table1 field1 data type is number with table2 field1 data type text.

I've tried CInt(table2.field1) in SQL but doesn't like this:

SELECT table1.field1, table2.field1,
FROM table1 LEFT JOIN table2 ON table1.field1 = CInt([table2].[field1])


Any ideas folks?

Cheers,
Mudz

Show Item Text When Dragging A Treeview Node
Does anybody know how when dragging a treeview node, to display the text property of the node as well as the DragIcon. I want to be able to replate the drag drop behaviour of Windows Explorer, i.e while you are dragging a folder, you can see the folder name in transparent text.

I have no problem setting the DragIcon property from an imageList I have associated with the treeview. For example in the DragOver event I am setting the DragIcon based on whether the mouse is over a valid drop point. E.g. .DragIcon = LoadResPicture("NoDrop", vbResCursor)

However it only shows the DragIcon and nothing else when dragging the node. Any help appreciated.

SELECT * FROM TABLE WHERE FIELD = TEXT BOX Question
Hi
can anyone tell me how it is possible to have a select statement like
SELECT (fields) FROM (table`)
WHERE (table.field0text box)

????

Combo Box And Text Field Problem
Hi!

I have a text field...(textbox) that has vertical scroll, and the multyline is enabled...
I want to enter something like:

test
record
wowow

I also have a combo box, and a button. I want, when I press the button, to have these things in the combo...the problem is that when i write:
Private Sub update_Click()
list1.AddItem Text1.Text
End Sub

The whole text goes to one position in the combo... I want every line to be in new position...

Sorry for the dumb question... I am very very newbie in VB...

Thanks!

Combo Select Shows Text Box
How do i write the following in vb?...

If i have a combo box called cbo_NoOfPieces. The numbers 1 to 10 are displayed inside the combo box. When the user clicks number 2 then i want to display 2 text boxes.

If the user selects 3 from the combo box i need to display 3 text boxes. and so on...

any ideas?
ta

Insert Combo Box Text Into Database Field
First of all, Hello to all vbcity forum users.

Now to my question....

How do I type in new data into a combo box or data combo box (which is not in the existing list) and automatically add that data into the database field?

Dynamically Sized Combo Box (select Text)
I have a combo box that has a lot of info in it.
The width of the combo box is enlarged when the dropdown event.
Then It is reduced on the lostfocus or click event.

The problem is that when I select something, the left most text is displayed in the combo box after the selection is made and focus is lost.

I though all I needed to do was set the .SelStart and .SelLength properties but that doesn’t work.

How do I make the left most part of the string appear in the combo box after the focus is lost?

EXAMPLE:
The list Item is “1 Item Number One is here.”
The static width of the combo box is such that I only see the first few chars (“1 “).
Then I click on the combo box and enlarge it so the user can see the whole list item.
But when the lost focus event happens, the user can see only the right most part (“ here.”)
I want the user to see the left part (“1 “).


Any help would be greatly appreciated.

Regards,

How To Select Info. Form Combo Box Into Text Box
Hi

I have one text box and one combo box. I have some list item under combo box. How can I click (double click???) one of them on combo box and it will be showed on text box?

Select Item In ListBox1 And Corresponding Item In ListBox2 Is Also Selected
Hi,
Hi I have two Listboxes list1 has lets say Firstname in List1 and List2 has surnames.
How do I select an item in List1 and have it's corresponding item in List2 selected as well?

So if I select Item 6 in List1, I want item6 in List2 to be selected too.

Ken

Combo Width Is Too Narrow, Can I Show A Label Flag Something To Show The Whole Content?
Combo width is too narrow, it can not show the whole info I want to show. I wonder if I can show a label flag something to show the whole content?

Best Regards,

Kevin Shen

Making The First Combo Box Item Always The Selected Item
Hi.

I have a combo box with a Dropdown list Style and which is invoked several times in different parts of my form. How can I make the first item in this combo box the selected item or the default item everytime I select it? Currently, what's happening is that the last item that I selected becomes the selected item the next time the combo box is invoked. Thanks for any suggestions in advance!

Flexgrid Select Call_Id Row And Put Call_Id Into Text Field
Dear All,

I need to do my final year project in school and i face problem in this part. Hope you all can help me. Here is my problem :-

First of all, in the flexgrid, there is a different Call_Id. I have to select a particular row that i wanted from the flexgrid. Then, how can i make the Call_Id of the particular row that i've selected to be pasted in the text field of another form?The another form contains 4 tabs. Here is my code that hv problems:-


VB Code:
Private Sub cmdCheck_Click() Dim rst As New ADODB.Recordset    With fg        .Col = .FixedCols        .Row = .RowSel        .ColSel = .Cols - 1'        Call_Id = .TextMatrix(.MouseRow, 1) '1 is the column with the ID, if its not 1 change this        CallTracker.Show        txtCalId.Text = fg.TextMatrix(Row, 0) = rst!Call_Id    End With




VB Code:
Private Sub Form_Load()... sSQL = "Select * From CallTracker Order By Call_Id"   Set oRS = db.Execute(sSQL)  i = 0    fg.Clear        DisplaySQL = "SELECT * FROM CallTracker"    Set rst = db.Execute(DisplaySQL)        fg.ColWidth(0) = 900        fg.ColWidth(1) = 1000        fg.ColWidth(2) = 2000        fg.ColWidth(3) = 1500        fg.ColWidth(4) = 1700        fg.ColWidth(5) = 2500        fg.ColWidth(6) = 1050        fg.ColWidth(7) = 1050         Row = 0                fg.TextMatrix(Row, 0) = "Call_Id"        fg.TextMatrix(Row, 1) = "Customer ID"        fg.TextMatrix(Row, 2) = "Customer Name"        fg.TextMatrix(Row, 3) = "Branch"        fg.TextMatrix(Row, 4) = "Site Contact"        fg.TextMatrix(Row, 5) = "Remarks"        fg.TextMatrix(Row, 6) = "Date In"        fg.TextMatrix(Row, 7) = "Time In"             Row = Row + 1            Do Until rst.EOF                fg.Rows = rst.RecordCount + 1        fg.TextMatrix(Row, 0) = rst!Call_Id        fg.TextMatrix(Row, 1) = rst!CustId        fg.TextMatrix(Row, 2) = rst!CustName        fg.TextMatrix(Row, 3) = rst!Branch        fg.TextMatrix(Row, 4) = rst!SiteContact        fg.TextMatrix(Row, 5) = rst!Remarks        fg.TextMatrix(Row, 6) = rst!DateIn        fg.TextMatrix(Row, 7) = rst!TimeIn                   Row = Row + 1        rst.MoveNext                Loop         Exit Sub



Hope there is anyone can help me as soon as possible.Hope to get a reply from you all. Thank you

Two Select Statements Using A Field From Select 1?
Ok I'm having a bit of a problem. Problem 1 is I'm working with someone elses tables and nothing was setup right but too many things uses these tables and they can't be changed.

Problem 2. I had data in 6 different tables that I need to extract (not every record from each table). So I made a table that looks like this.
ID - AutoNumber (Key)
Type - Text
RecordNum - Number
TableName - Text

My Table would look like this [Table name = LISTS].
1 US 5 IPBs
2 US 7 IPBs
3 US 1 OrderForms
4 US 3 OrderForms
5 US 1 TNB
6 US 2 TNB
7 US 3 TNB
8 CA 1 IPBs
9 CA 2 IPBs
10 CA 1 OrderForms

And so on..
What I need is and SQL statement like this "select * from LISTS where type = US"
BUT return all fields from the "tableName" field table where ID = the "RecordNum" field.

I could just say
SELECT * FROM LISTS WHERE Type = 'US'
Do While Not rs.EOF
SQL = "SELECT * FROM " & rs("TableName") & " WHERE ID=" & rs("RecordNum")
rs.movenext
Loop

but that seems like way too much work (for my program).. Is there a way to build a select statement with two SELECTS in it based off a field returned?

TextBox Field In Form1 Should Automatically Show Up In TextBox Field In Form2
I have budgeting problem where I want the Calculated Total Income Amount TextBox Field to appear and be the same Total Income Amount in Form2. When there are changes in the Total Income Amount in Form1 these same changes should appear in the Total Income Amount in Form2. Is there a way to link these two fields. Me.Form1 and Me.Form2 and so on.

I have always linked cells in Excel for Row1 in one worksheet with Row1 in another sheet. The same principle.

Thanks for any help

jjc9809

Show Last Item In Listview
Hello!

I'm using a listview in Excel Form. I'm add some itens manual (users entrys), but when the space defined to the listview ends the add item don't show in listview. The user must have to scroll the listview to see the add item.
It's possible to make automatic scroll of the listview to show the last add item ?
I can make this in the listbox, <userform.listbox1.ListIndex =userform.ListBox1.ListCount - 1 > but I can't make in the listview, because the propertys are diferent. I already try, but I can't do it

Thanks for the Help...

How To Show The Selected Item In A Listview?
I want to be able to show the selected item in a listview. I'll try to explain by an example.

Visible items:

Item 1
Item 2
Item 3
Item 4

Invisible items:

Item 5
Item 6
Item 7
Item 8

Now when I select Item 8 by the use of source code like this:

listview.listitems(8).selected = true

I want to scroll the listview so that the item becomes visible. So how do I scroll the listview to the selecteditem with source?

Show Last Item Added In Listview.
Hello there! I just wanted to ask if there's any way to display or go to the last item added in a listview. I have this attendance system and it's working out fine. But they want to see that during scanning, their name should be displayed as it's added to the listview. There will be no user intervention by the way as the computer is inside a cabinet with just the barcode scanner the interact with.

Show Individual Item In Listview
I have a problem seen the firs column in a listview

If i put

ListView1.ListItems(i).ListSubItems(0)
it gives an error index out of range.

If i put ListView1.ListItems(i).ListSubItems(1) it shows me the item in the second column. how do I see the info in the first one?

AddItem To Combo List And Have The Combo List Be Able To Retain The Item Upon Recall
I have a project that I need to do for school. You are to have a command button, a combo/dropdown list and a text box, you are to enter a name and birthday in the text box and when you click on the command button it is supposed to enter it in the combo box. My problem is that I got it to enter into the combo box with additem, but it will not retain the item that I just added. When I close the program the item I added does not stay there. How do I get the combobox to retain everything that I add through the textbox on command click. PLEASE HELP

Selecting Item In Listbox, Show Related Datas
I have a listbox which lists the names of all items in a table. When I click one of the items, I want the rest of the datas related to that item to show in the other textboxes.
My first problem is that I cant find an event that should fit. All I can find is the listbox_click, but that will be triggered without selecting an item, wont it?
My other problem is that Im not sure how to get datas related to the right item

Show Picture When Mouse Hovers Over ListView Item
Is there an easy way to show a picture when the mouse is hovering over a specific listview item?

I have been messing around with the listview but wasn't sure if there is an easy way to do this other then fudging it. I.E. setting a picturebox left and top, and visible when mouse is over it.

any preset or premade options with either the listview or another control?

Select Item In Combobox
Hello,

I'd like to select a value in a combobox. The combobox is filled wirh an array, the second column contains the search string.


Code:
l = Me.cmbGB1.ListCount
For i = 1 To l

If Me.cmbGB1.List(i, 1) = 8000 Then Me.cmbGB1.List(i, 1).Select

Next

Select All Item In ListView
Hi,

I just wondering if there is way to select all items in my list view.Let say I had 20 items in my list data,so how can I select all the items in one time.


Thanks.

How Do I Select The Last Item In A List?
I need to select the last item in a list no matter how big...how can I do this in a command click?

Select First Item In Listview
Hi,

I have a somewhat simple problem and I am wondering what the simplest way to handle it is. I have a treeview that I am loading with some information about files in a specific directory. The listview is set to automatically sort the list and after all the nodes are added, I want to have the top node in the treeview be selected. But I don't have a reference to the first node in the list. Are there any properties that I can use to get the node that is at the top of the list?

Thanks,
Jason O

Combobox Item Select
Hello, I have a combo box with 5 items on it, how can i display text pertaining to the select item in a text box when the user select's an item out of the combo box.

They click the wedge to drop down the 5 choices, and I want to be able to display information about their choice when they select it. I tried the change event, but that's only when you actually change the text of the box, I just want it to see when the text changes from Item1 to Item2. Is there any way of doing this without setting up a timer to constantly check the text in the box?

Thanks for any help. Appreciate it.

Select Item In ComboBox
How do I retrieve the "NAME" of the selected item in a combobox?
The selected item's Name will determine the items to be display in combobox2

How To De-select A List.item
If an item in a list has been selected, how do you de-select it?

Listview Select Item
In a listbox I select an item with: listbox.listindex = 0

I want to do the same thing with a listview.
I tried with: listview.SelectedItem = listview.ListItems(1)

But it does not work. Can anyone tell me what I'm doing wrong?

Select Item In DataList
This should be easy for you.
I have looked for this in the forum but haven't found any good answer.
Maybe a poor search, it should be present one would think.

I have a form consisting of a DataList that is populated by a recordset from an SQL query. (Not an Adodc, it's written in code).
When the form is shown I want the first item in the DataList to be selected.
How do I do that?

Cheers.

/Mats

I Want To Select A Particular List Item
I have tried this

If frmItems.lstitems.listIndex = "Unknown"
frmItems.lstitems.RemoveItem frmItems.lstitems.ListIndex
End If

i want it to see if the item unkown is in the list of the listbox and then remove it

Item.key Problem In Sql Select
This is similar to my other post, but a little different code. Still can't get the error fixed, but i know the right id is being retrieved because it even says the correct id in the error. still keep getting a syntax error that says missing operator.

Dim rsIclick, SQL, intMediaId
Set rsIclick = New Recordset

SQL = "Select mediaid from media_tbl where " & _
"mediaid=" & Item.Key
Set rsIclick = conn.Execute(SQL)
intMediaId = rsIclick("MediaId")
MsgBox (rsIclick)

Select Item From MSHFlexGrid
I know that there are posts that come close to answering this question and I even got the code from the MakeDB Project which will help in other areas of the program. But what I need to do is have the user be able to click on an item in the populated recordset of an MSHFlexGrid and this action will populate the text boxes of another form.
The Idea is they bring up a form(form1) to edit items in the database. they are presented with a Select Item button that opens a form(form2) with the MSHFlexGrid on it that is populated with items in the database. They click the item, form2 is unloaded and form1 has all the fields filled in.

The grid is populated with the following code
Private Sub Form_Load()
Dim objrs As New Recordset
mySQL = "SELECT Description, Manufacturer, Category, Location FROM Items"
g_Conn.CursorLocation = adUseClient

objrs.Source = mySQL
Set objrs.ActiveConnection = g_Conn
objrs.Open
Set flexSelect.DataSource = objrs
DoInitialSettings
End Sub

g_Conn is an ADODB.connection made in a module at program startup


Any help will be appreciated.

Michael

Select A Item In Listview
hi,
i want to select a item in listview by code like this:
listview.ListItems(100).Selected =true
this work but if a have more than x items and if a don´t see the items that i selected the lisview don´t do the scroll down.
In a list1 control we have the listindex that can do the scroll down/up of the list, but in listview who we can do that?
thanks a lot for your help
bruno

ListView, Don't Want To Be Able To Select An Item
As the title says, I don't want to be able to select an item, I just want to list data, that's it.

I tried to unselect an item whenever i select one, but it still shows a doted rectangle around the selection.

This is the code I tried, but it does not really work.

VB Code:
Private Sub ListView1_ItemClick(ByVal Item As MSComctlLib.ListItem)    Item.Selected = FalseEnd Sub

Want To Select Item In TreeView
I have a treeView populated and upon an action I want a specific item to be highlighted in the TreeView, is that possible??

Copyright © 2005-08 www.BigResource.com, All rights reserved