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




Selecting An Item In ComboBox


How do I select the item in the ComboBox. The selected item will determine what will be inserted in ComboBox2.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Selecting A Item From A ComboBox
Hi,

I have a form which allows users to enter details and save them to a table in a access database. Users use a mix of text boxes and ComboBoxes to enter the required data.

I have comboboxes which pull data from two lookup tables and insert the ID of their selection in the table which is great.

The problem comes when I come back to this form to view the entered data.

Both the ComboBoxes are empty. How can I get the ComboBoxes to set their default value to match that of their corresponding value in the table.

Heres my code so far:


Quote:





Private Sub Form_Activate()
'On Error GoTo errHandler
Dim sSql As String
Dim adoRSA As ADODB.Recordset
Dim adoField As ADODB.Field
Dim lCol As Long
Dim lRow As Long
Dim lWidth As Long
Dim labEntry As Label
Dim txtEntry As TextBox
Dim vArr As Variant
Dim lX As Long
Dim sHide As String

If Me.Tag = "loaded" Then Exit Sub

Me.Tag = "loaded"
Me.Icon = frmAccount.Icon
'txtEdit.Visible = False

'load IP details
sSql = "SELECT IPdetails.* " & _
"FROM IPdetails WHERE Clis = " & glCli
Set adoRS1 = gadoConnDB.Execute(sSql)

If Not adoRS1.EOF Then
'If adoRS1(tickProgrammed.DataField) Then
'tickProgrammed.Value = 1
'Else
'tickProgrammed.Value = 0
'End If
For Each txtEntry In txtIPDetails
txtEntry.Text = adoRS1(txtEntry.DataField)
'If tickProgrammed.Value Then
'txtEntry.BackColor = &H8080FF
'Else
'txtEntry.BackColor = &H80000005
'End If
Next
'framePBX.Tag = .TextMatrix(.Row, 2) 'save lCli
Else
For Each txtEntry In txtIPDetails
txtEntry.Text = ""
txtEntry.BackColor = &H80000005
Next
'tickProgrammed.Value = 0
'framePBX.Tag = .TextMatrix(.Row, 2) 'save lCli
End If

Dim strSQL As String 'Declare the variables we need
'Load the data
'** change this SQL to load the data you want.
strSQL = "SELECT * FROM PackageType"
'** change oConn to the name of your Connection object
Set adoRScombo1 = gadoConnDB.Execute(strSQL)

'Fill the combo box (or ListBox)
'** change the name of the combo to the one you want to fill
With CboPackageType
.Clear
'Do While Not adoRScombo1.EOF
'** change the name of the field here to the one you want to show
'.AddItem adoRScombo1.Fields("Package").Value
'adoRScombo1.MoveNext

Do Until adoRScombo1.EOF
CboPackageType.AddItem adoRScombo1.Fields("Package").Value & ""
CboPackageType.ItemData(CboPackageType.NewIndex) = adoRScombo1.Fields("PackageId").Value
adoRScombo1.MoveNext
Loop

'If CStr(CboPackageType.ItemData(CboPackageType.NewIndex)) = CStr(adoRS1("Package")) Then
'CboPackageType = True
'Else
'End If

End With


'Tidy up
adoRScombo1.Close
Set adoRScombo1 = Nothing


Dim strSQL2 As String 'Declare the variables we need
'Load the data
'** change this SQL to load the data you want.
strSQL2 = "SELECT * FROM ProviderName"
'** change oConn to the name of your Connection object
Set adoRScombo2 = gadoConnDB.Execute(strSQL2)

'Fill the combo box (or ListBox)
'** change the name of the combo to the one you want to fill
With CboProviderType
.Clear
'Do While Not adoRScombo2.EOF
'** change the name of the field here to the one you want to show
'.AddItem adoRScombo2.Fields("Provider").Value
'adoRScombo2.MoveNext

Do Until adoRScombo2.EOF
CboProviderType.AddItem adoRScombo2.Fields("Provider").Value & ""
CboProviderType.ItemData(CboProviderType.NewIndex) = adoRScombo2.Fields("ProviderId").Value
adoRScombo2.MoveNext
Loop


End With


'Tidy up
adoRScombo2.Close
Set adoRScombo2 = Nothing




End Sub

Private Sub cmdUpdateContact_Click()
Dim sSql As String
Dim adoRS1 As New ADODB.Recordset
Dim txtEntry As TextBox

'update ip data
sSql = "SELECT IPdetails.* " & _
"FROM IPdetails WHERE Clis = " & glCli
adoRS1.Open sSql, gadoConnDB, adOpenStatic, adLockOptimistic

If adoRS1.EOF Then
adoRS1.AddNew
End If
adoRS1("Clis") = glCli
adoRS1("Package") = CboPackageType.ItemData(CboPackageType.NewIndex)
adoRS1("Provider") = CboProviderType.ItemData(CboProviderType.NewIndex)
'If tickProgrammed.Value = 0 Then
'adoRS1(tickProgrammed.DataField) = False
'Else
'adoRS1(tickProgrammed.DataField) = True
'End If
For Each txtEntry In txtIPDetails
adoRS1(txtEntry.DataField) = Trimmer(txtEntry.Text)
Next
adoRS1.Update

cmdUpdateContact.Enabled = False

End Sub

Selecting Combobox Item???
How do I select a comboBox item by its text, not its index ID and how do I do it through code?

Thanks

Selecting A Item From A ComboBox
Hi,

I have a form which allows users to enter details and save them to a table in a access database. Users use a mix of text boxes and ComboBoxes to enter the required data.

I have comboboxes which pull data from two lookup tables and insert the ID of their selection in the table which is great.

The problem comes when I come back to this form to view the entered data.

Both the ComboBoxes are empty. How can I get the ComboBoxes to set their default value to match that of their corresponding value in the table.

Heres my code so far:

------
Private Sub Form_Activate()
'On Error GoTo errHandler
Dim sSql As String
Dim adoRSA As ADODB.Recordset
Dim adoField As ADODB.Field
Dim lCol As Long
Dim lRow As Long
Dim lWidth As Long
Dim labEntry As Label
Dim txtEntry As TextBox
Dim vArr As Variant
Dim lX As Long
Dim sHide As String

If Me.Tag = "loaded" Then Exit Sub

Me.Tag = "loaded"
Me.Icon = frmAccount.Icon
'txtEdit.Visible = False

'load IP details
sSql = "SELECT IPdetails.* " & _
"FROM IPdetails WHERE Clis = " & glCli
Set adoRS1 = gadoConnDB.Execute(sSql)

If Not adoRS1.EOF Then
'If adoRS1(tickProgrammed.DataField) Then
'tickProgrammed.Value = 1
'Else
'tickProgrammed.Value = 0
'End If
For Each txtEntry In txtIPDetails
txtEntry.Text = adoRS1(txtEntry.DataField)
'If tickProgrammed.Value Then
'txtEntry.BackColor = &H8080FF
'Else
'txtEntry.BackColor = &H80000005
'End If
Next
'framePBX.Tag = .TextMatrix(.Row, 2) 'save lCli
Else
For Each txtEntry In txtIPDetails
txtEntry.Text = ""
txtEntry.BackColor = &H80000005
Next
'tickProgrammed.Value = 0
'framePBX.Tag = .TextMatrix(.Row, 2) 'save lCli
End If

Dim strSQL As String 'Declare the variables we need
'Load the data
'** change this SQL to load the data you want.
strSQL = "SELECT * FROM PackageType"
'** change oConn to the name of your Connection object
Set adoRScombo1 = gadoConnDB.Execute(strSQL)

'Fill the combo box (or ListBox)
'** change the name of the combo to the one you want to fill
With CboPackageType
.Clear
'Do While Not adoRScombo1.EOF
'** change the name of the field here to the one you want to show
'.AddItem adoRScombo1.Fields("Package").Value
'adoRScombo1.MoveNext

Do Until adoRScombo1.EOF
CboPackageType.AddItem adoRScombo1.Fields("Package").Value & ""
CboPackageType.ItemData(CboPackageType.NewIndex) = adoRScombo1.Fields("PackageId").Value
adoRScombo1.MoveNext
Loop

'If CStr(CboPackageType.ItemData(CboPackageType.NewIndex)) = CStr(adoRS1("Package")) Then
'CboPackageType = True
'Else
'End If

End With


'Tidy up
adoRScombo1.Close
Set adoRScombo1 = Nothing


Dim strSQL2 As String 'Declare the variables we need
'Load the data
'** change this SQL to load the data you want.
strSQL2 = "SELECT * FROM ProviderName"
'** change oConn to the name of your Connection object
Set adoRScombo2 = gadoConnDB.Execute(strSQL2)

'Fill the combo box (or ListBox)
'** change the name of the combo to the one you want to fill
With CboProviderType
.Clear
'Do While Not adoRScombo2.EOF
'** change the name of the field here to the one you want to show
'.AddItem adoRScombo2.Fields("Provider").Value
'adoRScombo2.MoveNext

Do Until adoRScombo2.EOF
CboProviderType.AddItem adoRScombo2.Fields("Provider").Value & ""
CboProviderType.ItemData(CboProviderType.NewIndex) = adoRScombo2.Fields("ProviderId").Value
adoRScombo2.MoveNext
Loop


End With


'Tidy up
adoRScombo2.Close
Set adoRScombo2 = Nothing




End Sub

Private Sub cmdUpdateContact_Click()
Dim sSql As String
Dim adoRS1 As New ADODB.Recordset
Dim txtEntry As TextBox

'update ip data
sSql = "SELECT IPdetails.* " & _
"FROM IPdetails WHERE Clis = " & glCli
adoRS1.Open sSql, gadoConnDB, adOpenStatic, adLockOptimistic

If adoRS1.EOF Then
adoRS1.AddNew
End If
adoRS1("Clis") = glCli
adoRS1("Package") = CboPackageType.ItemData(CboPackageType.NewIndex)
adoRS1("Provider") = CboProviderType.ItemData(CboProviderType.NewIndex)
'If tickProgrammed.Value = 0 Then
'adoRS1(tickProgrammed.DataField) = False
'Else
'adoRS1(tickProgrammed.DataField) = True
'End If
For Each txtEntry In txtIPDetails
adoRS1(txtEntry.DataField) = Trimmer(txtEntry.Text)
Next
adoRS1.Update

cmdUpdateContact.Enabled = False

End Sub

------

ComboBox Highlight Item W/o Selecting
Is there any way to highlight a combobox item without selecting the item?

Displaying A Combobox Item By Default Without Selecting It?
Hi folks,

How do you make an item in the combobox to be displayed automatically by default when you start the program?



Thanks

ComboBox - Selecting Part Of An Item After Adding AddItem
I add like 6 positions of data from a Recordset to a combobox, with .AddItem

Then I would like to only select a certain part of the string that is added to the combobox to textbox when the user has selected a row in the combobox.

In a flexgrid this can be done by ex. flexgrid.TextMatrix(lngRowSel, 0)

Is it possible in a way to gey part of combobox data?

Thanks in advance

Single Item List Box (item Not Really Selecting)
Application=Access2002

The following code has worked for me in the past but won't now for some reason.
I have a private function and/or subs that performs a few simple operations such as setting listbox rowsources and simple math functions on a form. The queries set as rowsource use criteria from other single item listboxes.
Now, for some reason, the queries won't return values until the previously .selected(0) = true (single item) list boxes have been clicked on.
Problem has only been in creating a new form. Perhaps the problem did not occur in older created forms due to compatibility?


Private Sub fraEWTo_AfterUpdate()

[Edited]
    lstRotorHoursPriorTo.RowSource = "qryRotorSwapHoursTotTo" 'gets hoursprior from tblRotors
    lstRotorHoursPriorTo.Selected(0) = True ' This is one place where the problem seems to exist, the control does not function until it has been clicked on via mouse.

    LstClockInTo.RowSource = "qryRotorSwapRAHoursIPTo"
    LstClockInTo.Selected(0) = True

    txtRACHIPTo.Locked = False
    txtRACHIPTo.Value = txtClockHoursTo.Value - lstClockInTo.Value 'nor will this until the lstClockInTo box has been manually selected


A Mechanic in a Programmers shoes
Thanks




Edited by - greenfch on 12/7/2005 11:22:52 AM

ComboBox List/add Item, If Item Exists, Dont Add It Again!
Dudes and Dudeesses I need help!

I have a problem with a combobox within a form. I'm scanning down the spreadsheet for values and asking a combobox to .additem, however, the same value may appear twice whilst scanning down. Is there an if statement that will look and check the combobox to see if it is already added, if so dont add it again, if not, add it?

as below,

Code:
combobox.AddItem "Hotmail"
combobox.AddItem "Yahoo"
combobox.AddItem "Hotmail"
Hotmail will be added twice, how can I stop that?

If worst comes to the worst, I can sort it out with a long winded method, but I'm hoping theres a quicker way.

Thanks for all your help

Combobox: Automatch Item, Select In Other Combobox, Remove From Both
I have 2 comboboxes and a listbox. I want the user to select an item from one combo, with then matches the item to its corresponding item in the 2nd combo, then add both to a list box. The user can either select from the 1st combo or from the 2nd...either one will match to the corresponding item in the other. Both comboboxes also have to be autocompleting. Once the selection is added to the listbox, the user can remove it which will delete the item from the list and add them back into the appropriate comboboxes. I have this working except for one thing.

When autocompleting, if the user types in what they want and its found and they hit ENTER, I am getting an error when trying to remove the item from the combos. It tells me the index is invalid and sure enough, when I check what the index is, its -1. It seems that the user isn't selecting an item in the combo even though its matched.

This is what I tried. It works if an item is clicked or chosen by pressing the up/down arrows. It also works if they type what they want, its matched, then they press up/down or some other number but will NOT work if they just type it, its found and they hit enter:


Code:
Private Sub cmdAdd_Click()
List1.AddItem cmbo(0).Text & " " & cmbo(1).Text

cmbo(0).RemoveItem (cmbo(0).ListIndex)
cmbo(1).RemoveItem (cmbo(1).ListIndex)

End Sub

Oddly, if I put the opposite combo item to be deleted, it works...so, if I just selected something from combo 1, the following works:


Code:
Private Sub cmdAdd_Click()
List1.AddItem cmbo(0).Text & " " & cmbo(1).Text

cmbo(0).RemoveItem (cmbo(1).ListIndex)
cmbo(1).RemoveItem (cmbo(1).ListIndex)

End Sub

Any ideas anyone? Perhaps I need to post the function I use for autocompleting? Let me know please...

ListView Selecting An Item
Dear friends

I'm using ListView control, but I'm having problems to select/focus an datermined cell in the grid.
For example, I click in the second cell in the third line, nut thw focus alway happen to the first cell of the third line.
How I do to select/focus the cell that the user clicks?
Thanks and sorry about my bad english.

Selecting An Item In A Listbox
I was using this following code to select the item in the combobox I needed but now I need to just be able to specify the ID of the number and it select it in the combobox. Can anyone shed some light?


Code:
Sub LoadBillToList(ItemName, ItemID)
If ItemID = "" Then
ItemID = 0
End If
frmInvoices.txt_BillToID.Clear

If strDBOpen = 0 Then
OpenDatabase
End If
strSql = "SELECT ID, CompanyName "
strSql = strSql & "FROM BillTo "
strSql = strSql & "ORDER BY CompanyName asc"
Set rs = my_Conn.Execute(strSql)

If rs.EOF Or rs.BOF Then

Else

frmInvoices.txt_BillToID.AddItem ItemName
frmInvoices.txt_BillToID.ItemData(frmInvoices.txt_BillToID.NewIndex) = ItemID
strTempI = 2
Do Until rs.EOF Or rs.BOF
strBillID = rs("ID")
frmInvoices.txt_BillToID.AddItem rs("CompanyName")
frmInvoices.txt_BillToID.ItemData(frmInvoices.txt_BillToID.NewIndex) = rs("ID")
rs.MoveNext
strTempI = strTempI + 1
Loop
End If
rs.Close
Set rs = Nothing
CloseDatabase
End Sub

Selecting An Item In A Text-box....
I hate to continue to bug, but I can't seem to figure out how to select an "item" in a list-box and have it perform an action (just by selecting it.)

I'm trying to display some info (a caption) that will change according to which list-box item is highlighted/selected.

I'm also needing to be able to delete the highlighted/selected item from the list and my .dat file when I press a "Delete" button...

Thanks.

Selecting Item From A Listbox
Hi, I could never figure this out. How do i select something from a listbox and make it do something. I have a listbox with user accounts for my game. and i dunno what command i would use to select it. because. i cant assign any items with an itemdata because its consistently changing with autoupdated accounts etc. and with Inventory Items etc... Is there any way to select a listbox item without any Assigned Itemdata?? if so.. Can N e 1 help me? Thanks. I have tried pretty much everything i can think of. Thanks.

Selecting An Item In ListView
how do i programmatically select an item in a listview based on its key?

Selecting An Item In An Array
i have an array of scroll bars, how can i find out the index of which one has focus?

Selecting Last Item In Listbox
I have an Access form that has an Access ListBox. When adding items to the listbox via form controls (Access ComboBoxes, etc), the VBA will do the .ReQuery method of the Access ListBox. When that happens, the ListBox's scrollbar stays in the same place in the list (i.e doesn't move.) Is there a way to use the SendMessage API or another API call to move the scrollbar to the bottom of the list after my app runs the .Requery method? I want this so that the users can always see the last items entered into the ListBox.

Selecting A Menu Item
I've been trying for a few days now to select a menu item using API. I just can't do it. I've tried to send the WM_COMMAND, WM_MENUSELECT, and various others but to no avail... can someone give me a good description of how to do this? I know my code works as far as finding the proper submenu handle and menu item ID, but from there I don't know how to send a message that will select that menu item like a mouse click would normally do. Thanks very much!

Selecting A List Item
I have a listbox and it is labeled A-Z. isit possible to have it where when the application starts it automaticly picks Z?

Selecting Item In Listbox
I can load items into a list box at Form_Load with no problems. Is it possible to process code based on the users selection from the list without using a command button.

Selecting Item In Listbox
I have this code:


Code:
For i = lstKeywords.ListCount - 1 To 0 Step -1
If InStr(lstKeywords.Text, strFilter(k)) Then
MsgBox "Found negative keyword" & lstKeywords.Text
lstKeywords.RemoveItem i
End If
Next i


But it doesn't loop through each item in the listbox. I don't know how to point to a specific row in the listbox and hence my problem. I know I should be using i somehow but not sure what the method is.

Do I use lstKeywords.Selected(i) or something like that?

Selecting An Item In A Listbox
Hi All,

I have a listbox with a popup menu when I right-click on one of the names in the list. This all works fine, but in order to make this work properly I have to first left click on the name I want to select, then I can right click to bring up the popup menu.

I'm wondering if there is a way I can just right click directly onto my chosen name in the listbox without first having to left click to select it?

Anyone have any ideas?

Thanks,

Selecting Combo Box Item Vb6
if i have a combobox with this items:

VB Code:
cmdButtonStyle.Clear        cmdButtonStyle.AddItem ("Normal")    cmdButtonStyle.ItemData(cmdButtonStyle.NewIndex) = 0        cmdButtonStyle.AddItem ("Soft")    cmdButtonStyle.ItemData(cmdButtonStyle.NewIndex) = 1        cmdButtonStyle.AddItem ("Flat")    cmdButtonStyle.ItemData(cmdButtonStyle.NewIndex) = 2


how do i get the combo box to select Soft on formload (ie without user selecting it).

sorry if its a simple vb question (at least it will be easy to answer it then).

Selecting Item In Combo
Hi, I have a combo box with items in it. I want to put in a line of code so that when the user presses a cancel button the first ite in the combo box will be selected. Can anyone give me this code please?

Thanking you in advance for your time and help.
PORRASTAR

Selecting A Item In A List Box
How can I select a spesific item on a listbox, without having focus on it? For example:

In a textbox I write: vb

The listbox's selection jumps to: vbforum

how do I do this?

ListBox - Selecting An Item In Another Box
Hey there,
I'm sure this is a realyl easy one but I can't seem to find it in the books I have.

I have two list boxes (we'll call them lst1 and lst2). Each have the same number of items in them. I want to set it so that when one of the items in either box is selected, it automatically selects the corresponding item in the other box so they are both highlighted.

Can someone help me out with this?

I can get which item is clicked with lst1.listindex but then how to I make that same index numebr in the other box get selected?

Thanks,
--Mike

Selecting An Item In A Combo Box
I have a combo box ( style = vbComboDrop-DownList) which displays a list of countries.

My problem is given a particular country name (string) how do I select that item in the combo without having to iterate through each item of the combo.

For example , so far what I have been doing is this
Combo1.text = "United States of America"

but just found out that if the string doesn't exist in the list then I get a run time error 'property is read-only'. eg. when I try to set the text property.

Selecting An Item From A ListView
Here is what MSDN says to do to select an item from a listview:
"
To programmatically select a ListItem object, use the Set statement with the SelectedItem property, as follows:

Set ListView1.SelectedItem = ListView1.ListItems(1)
"

I cannot seem to get it to work. Is there a property that I need to set or I have set wrong?

Here is a simple example that I am trying to get to work without any luck:

Private Sub Command1_Click()
Set lstView1.SelectedItem = lstView1.ListItems(1)
End Sub


I cannot get this to do anything.
Any ideas??

Listbox Item Selecting
I'm using VB5. I want to highlight and copy a number of items in a listbox to the clipboard. I can only highlight one item at a time.

SELECTING AN ITEM FROM A COMBO BOX
Hello all,
Im in the middle of a project that asks me to create a sequential file and add data to it i.e. a message , then a date, so that they are linked, however the dates from this file should then be automatically added to a combo box on the form so that a user can click a date and the related message will appear in the picture box next to it. Ive managed the sequentail file part and iv added the dates to the combo box but i cant find the code that will display the message when a date is chosen by the user. I can manage it with a list box as i use the listbox.selected (I) option but that is not available for a combo box and I have to use a the combo box in the project.
I also cant find the code to relate that date to the message stored in the sequential file so that it can be shown in the picture box. Can anyone help
Here is the code I have so far
Code:
Option Explicit
Dim intstarlog As Integer
Private Type Starlog
strMessage As String
strDate As String
End Type
Dim recLog As Starlog
Private Sub Form_Load()
 Dim Starlog As Integer
Starlog = 1
Open "C:Starlog" For Output As #Starlog
Close #Starlog
End Sub
Private Sub cmdAdd_Click()
Dim intmem As Integer
 Dim Starlog As Integer
recLog.strMessage = ""
 recLog.strDate = ""
recLog.strMessage = InputBox("Please type your message in now", "Star Log")
recLog.strDate = InputBox("Please type in the date,Example :--/--/----", "Star Log")
Starlog = 1
Open "C:Starlog" For Append As #Starlog
Write #Starlog, recLog.strMessage, recLog.strDate
 Close #Starlog
 comDate.AddItem recLog.strDate
For intmem = 0 To comDate.ListCount - 1
If comDate.ListIndex >= 0 Then
picDisplay.Print recLog.strMessage
End If
Next intmem
End Sub
Again thanks for any help
chris

VB6 Selecting More Than One Item From A Grid
I am using VB6 and I wanted to know how can I select multiple items and store selected/highlighted items into an array or something from a Grid? What kind of Grid do you think I should be using? Right now I am trying it out with MSHFlexGrid, but I cant figure out how to iterate through highlighted items.

Thanks
PJOFNJ

Selecting A DataCombo's Item
I have populated a data combo as given:

Set DataCombo.RowSource=RecSet
DataCombo.ListField="Field1"
DataCombo.BoundColumn="Field2"

At runtime no item is dispayed in combo, unless we select one from the populated items. I want that whenever the form containing DataCombo is loaded, combo's first item is selected.

Any Help...

Selecting/Highlighting Item Within Listbox (with VBA)
How do I select a given item within a listbox using VBA? I have a listbox that records ranges from a Refedit control. However, if the user has selected an invalid range, I want to let them see a meaningful message, set the focus to the listbox and then select/highlight the invalid range.

Displaying the message and setting the focus to the listbox is easy, but selecting the item is something I don't know how to do.

Any suggestions?

Selecting Item In Listbox With Right-click
Hi,

Is it possible to select a item in a listbox with a right-click of the mouse. I have a popup menu that must run when the right mouse button is clicked on a item in the listbox.

The problem is that the item is not selected when I right-click on it. The popup menu displays 100% but the item stays unselected. I first have to left-click on the item to select it and then right-click to popup the menu.

Bezzie

ContextMenu, Selecting ListBox Item After
Code:
Private Sub ClientList_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

'If Right Click on Client List, Give Menu For Kicking
If Button = 2 Then
PopupMenu SelectClient
End If

End Sub

My code above is for right clicking the client listbox and bringing a contextmenu to the screen. However, I also want it to select the item (Like a left mouse click) if there is not one selected. Also I do not want the feature of right clicking in the clientlist anywhere. I want to select an item first and only be able to rightclick within the item selected. How would I go about doing this? I have been through many pages on the search forum, I didn't find how to accomplish this... unless I am looking under the wrong words, listbox selection, contextmenu selection... The problem is I can rightclick anywhere in the client listbox without selecting an item, and need to force selection.

I tried syntaxs, .list, .listindex, .selected, .listcount, and some others, but I am pretty sure these won't work, I kind of just need a physical selection. Can anyone help?

Combo Box Event For Selecting An Item.
I keep encountering a problem using combo boxes and I need some help.

I'm using a combo box in 2-dropdown mode. I want to respond to whenever the user changes the ListIndex in the combo box. None of the events that are part of the combo box control seem to allow me to do what I want.

Any suggestions.

Thanks.

Selecting An Item In A Listbox Without Clicking
hi,
all day yesterday i've been searching for a code like this but the closest thing can find is a listbox search and its close but not exactly what i want.

lets say i have

a List, a textbox, and a command button.

there are different items in that listbox.

how can i have it so i can type the (exact) name of the item that i'm looking for in the textbox, click the command button.

and then have that item be ***Selected***

the most imortant thing to me is having the item be selected in the listbox without me having to manually click on the listbox.

i can't find this anywhere that i've looked

if someone can help me i'd appreciate it.

Selecting Next Item In List Using A Timer
My program is selecting an item in a list and exectuing code. This is for entering chatrooms. You add the names of a few different chatrooms and click cycle. This code then cycles through the list until it finds a room on your list that isnt' full.

Now is what i want to do is cycle the room on a 5 min timer. I have the code for cycle every 5 minutes.

My problem is i want the cycle to start at the last room it entered. So if it entered the first room on the list, after 5 minutes i want to start to cycle at the 2nd room on the list and so on.

Here is the code i currently have

code:

StopBust = False
Do: DoEvents

inRoom = BustPrivate(List2.List(0))
If inRoom = False Then
inRoom = BustPrivate(List2.List(1))
End If
If inRoom = False Then
inRoom = BustPrivate(List2.List(2))
End If
If inRoom = False Then
inRoom = BustPrivate(List2.List(3))
End If
If inRoom = False Then
inRoom = BustPrivate(List2.List(4))
End If
Loop Until (inRoom = True) Or (StopBust = True)

end code:

Selecting The Nth Item In Several List Boxes
Hi

I was wondering is it possible to select say the fourth item in several list boxes so they are all highlighted in the same place. The coding would be greatly appreciated!

Selecting A ListView Item From ListBox
Hi,
How do you select a ListView value from selecting the value from a ListBox?

i can't work it out
LV.SelectedItem.index = LB.ItemData.index

Selecting First Item In Sorted Treeview
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

Selecting Item In Combo Box Via Code
What's the method to select an item in a combo box and make it show up in the closed combo box?
Eg. I populate a combo box with 15 items by code. Now nothing is selected. I want to make an item visible. What method do I use it and what is the syntax?
Thanks.

Selecting An Item In A Checked Listbox Using A Db
Hi,

I'm developing a program which connects to a ms access 2003 database using ADO, this database contains information about computer games. It has the following fields:

GameID
Title
Developer
MyGame

I'm trying to populate a checked listbox with the contents of the title field and then check all the titles which have "Yes" in the MyGame field. I managed to populate the list with the titles using this code...


VB Code:
'Clear the games list    frmMain.lstGames.Clear    'Set a new recordset to store the information from the database    Set rs = New ADODB.Recordset    rs.Open "Select GameID, Title, MyGame From Games", cn, , adLockOptimistic        Do Until rs.EOF        With frmMain.lstGames            .AddItem rs.Fields("Title").Value            .ItemData(frmMain.lstGames.NewIndex) = rs.Fields("GameID").Value        End With        rs.MoveNext    Loop


How would I place a check next to each game title which has "Yes" in the MyGame field?

Also is it possible to stop the user from placing or removing a checkmark when they click on the title in the listbox?

Many thanks in advance
Robert

Selecting Next Item In List Using A Timer
My program is selecting an item in a list and exectuing code. This is for entering chatrooms. You add the names of a few different chatrooms and click cycle. This code then cycles through the list until it finds a room on your list that isnt' full.

Now is what i want to do is cycle the room on a 5 min timer. I have the code for cycle every 5 minutes.

My problem is i want the cycle to start at the last room it entered. So if it entered the first room on the list, after 5 minutes i want to start to cycle at the 2nd room on the list and so on.

Here is the code i currently have

code:

StopBust = False
Do: DoEvents

inRoom = BustPrivate(List2.List(0))
If inRoom = False Then
inRoom = BustPrivate(List2.List(1))
End If
If inRoom = False Then
inRoom = BustPrivate(List2.List(2))
End If
If inRoom = False Then
inRoom = BustPrivate(List2.List(3))
End If
If inRoom = False Then
inRoom = BustPrivate(List2.List(4))
End If
Loop Until (inRoom = True) Or (StopBust = True)

end code:

Selecting An Item In A ListBox By Right-clicking
I'd like to be able to right-click items in a list-box and have them be selected so that I can open a popup menu to act on that item.

How can I do this?

Selecting Item In Combo Box In Access?
Hi,

I know how to select an item in a combobox in VB, but there doesn't seem to be any obvious way to do it in Access. Does anyone know how to do this in Access?

What I'm trying to do is to select the first item in the combox box upon Form_Load..

Any help would be appreciated..

Dan

Help With Selecting An Item In A Right Click Menu
Anyone know how to select (as in 'click') an item from a right click menu? for example, if i right clicked in IE, how would i 'click' or select the option "Set as wallpaper".. anyone know?

Selecting The Next (excel)pivottable Item Via VB
Hello,
I have a pivottable in Excel in which I want to select the first item, print the data, select the next, print the data etc until the last one. Not every item is always in the list.
Now I do it manual, but I want to automate it.
Now I have this VB:

**
Sheets("PivotInfo").Select
ActiveSheet.PivotTable
("PivotPosted").PivotFields("Dealer").CurrentPage = "item1"
ActiveWindow.SelectedSheets.PrintOut Copies:=1
**

Now I want the script to select the next item after item1 is printed.

Any help will be appreciated!

Thanks,
Mark.

Selecting Item From External Listbox
Hi there,

I'm in the same boat as member 'Pubulis', in that I posted this question to the API forum, however unfortunately no-one has been able to help me. Hopefully you more 'General' guys will ba able to help me here, (

(Please excuse any spelling errors that may follow due to large quantities on 'Stella Artois'?!?!?!?!?!?? )

I am writing some VB code that will automatically start up
a third party application.

When this third party application starts up, the user would
normally select two things - a session, followed by an
environment.

I can automatically select the session by passing in a
command-line parameter, however I am not sure how to go
about selecting an environment.

The environment options are listed in a ListBox control and
I have used the FindWindow & FindWindowEx API's, to get the
handle of this listbox

Can anyone tell me how to select an item from the Listbox
so the third party application starts-up completely.

Here is the code I have come up with so far....


Code:
Private Declare Function FindWindowEx Lib "user32.dll" Alias "FindWindowExA" (ByVal hwndParent As Long, ByVal hwndChildAfter As Long, ByVal lpszClass As Any, ByVal lpszWindow As Any) As Long
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As Any, ByVal lpWindowName As Any) As Long

Dim RetVal

'Start up the Third Party application, passing in a Command-Line parameter
RetVal = Shell("C:INFOCONNACCMGRACCMGR.EXE C:INFOCONNACCMGRENV1.XWP", 3)

'At this point the application has started and a session has been
'selected automatically. Now there is a listbox of available
'environments to choose from.

'Attempt to locate a window called "Select INFOConnect Path"

Dim hWnd As Long

hWnd = FindWindow(CLng(0), "Select INFOConnect Path")

If hWnd <> 0 Then
'The window "Select INFOConnect Path" has been found.
'Now look for the Listbox control

Dim hWndListBox As Long

hWndListBox = FindWindowEx(hWnd, 0, "ListBox", CLng(0))

If hWndListBox <> 0 Then
'ListBox has been found

'This is where I want to select an environment so
'that the application will start up completely
'without any interference from the user.

End If
End If


Thanks for your time. Any help would be much appreciated.
__________________

Automatically Selecting 1st Item In A DBCombo
I was wondering if anyone can tell me how to automatically select the first
item in a DBCombo list by default.

The DBCombo style I am using is: Type 2 dbcDropdownList

thanks in advance

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