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
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
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 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?
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 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 List Box In An External Program
Hello,
I am currently working on writing a program for work, and I have come across something that I dont know exactly how to do.
The program that I am working with runs while another program is running. The program I am writing is to "use" (act as a person using the program itself) the other program.
The program that this program is interfacing with and using has a big list box with a few thousand entries in it. This list box allows multiple items in it to be selected at once.
The problem at the moment is that a actual human has to look at an excel list, and then find these entries in this big list box, hold down the control button and click all of the items in the list that are on the excel sheet. What I am hoping to do is create a program that will read the excel sheet, get the contents of this list box, and then select the items in the list box that are also on the excel sheet.
I know how to do all the code so far except for the part of selecting the items in the actual list box.
Since the program that I need to select the item in the list box in is an external program (its not the program that I am coding, its the one I am coding this program to modify) I assume that in order to select the item I will have to use some sort of API code.
Any person that can help me out with this (tell me the API that I could use, give me a code example, whatever) to select an item in a list box in an external program, would be VERY appreciated.
Thanks a million,
John
Selecting An Item In A List Box In An External Program
Hello,
I am currently working on writing a program for work, and I have come across something that I dont know exactly how to do.
The program that I am working with runs while another program is running. The program I am writing is to "use" (act as a person using the program itself) the other program.
The program that this program is interfacing with and using has a big list box with a few thousand entries in it. This list box allows multiple items in it to be selected at once.
The problem at the moment is that a actual human has to look at an excel list, and then find these entries in this big list box, hold down the control button and click all of the items in the list that are on the excel sheet. What I am hoping to do is create a program that will read the excel sheet, get the contents of this list box, and then select the items in the list box that are also on the excel sheet.
I know how to do all the code so far except for the part of selecting the items in the actual list box.
Since the program that I need to select the item in the list box in is an external program (its not the program that I am coding, its the one I am coding this program to modify) I assume that in order to select the item I will have to use some sort of API code.
Any person that can help me out with this (tell me the API that I could use, give me a code example, whatever) to select an item in a list box in an external program, would be VERY appreciated.
Thanks a million,
John
Selecting An Item In A List Box In An External Program
Hello,
I am currently working on writing a program for work, and I have come across something that I dont know exactly how to do.
The program that I am working with runs while another program is running. The program I am writing is to "use" (act as a person using the program itself) the other program.
The program that this program is interfacing with and using has a big list box with a few thousand entries in it. This list box allows multiple items in it to be selected at once.
The problem at the moment is that a actual human has to look at an excel list, and then find these entries in this big list box, hold down the control button and click all of the items in the list that are on the excel sheet. What I am hoping to do is create a program that will read the excel sheet, get the contents of this list box, and then select the items in the list box that are also on the excel sheet.
I know how to do all the code so far except for the part of selecting the items in the actual list box.
Since the program that I need to select the item in the list box in is an external program (its not the program that I am coding, its the one I am coding this program to modify) I assume that in order to select the item I will have to use some sort of API code.
Any person that can help me out with this (tell me the API that I could use, give me a code example, whatever) to select an item in a list box in an external program, would be VERY appreciated.
Thanks a million,
John
ListView - Selecting First Item In List Causes Rename
I have an application with several Listview controls on it, in report view containing a few columns of data.
The application requires selecting some items in the ListView and adding them to another Listview.
My problem is that when the first item in the ListView is selected (only for the first item) It tries to let you rename the item, rather than merely selecting it.
Does anyone know if there is a way to stop this from happening?????
Selecting Item From List Box Then Write To Sequential File
Hiya All
What I'm trying to do is select an item from a list box (that has been read in from a sequential file, then into an array) search array for this item then write it to a new file named orders.txt.
The code i've come up with so far writes to the file but it's writing the item above what i've selected in the listbox.
Private Sub cmdOrder_Click()
Dim strOrdersFile As String
strOrdersFile = App.Path & "Orders.txt"
'create orders file
Open strOrdersFile For Append As #3
'Write information in data structure to file
Write #3, recSuppDetails(lstSupplierOrderData.ListIndex).strName, _
recSuppDetails(lstSupplierOrderData.ListIndex).strSerialNumber
Close #3
End Sub
Cheers for any help this is really doing my head in
How To Avoid Opening Input Box After Selecting And Item From List Box...
guys i have a annoying problem in my program that i cannot solve for the life of me.
In my program when i click on my list box it brings up an input box that i must enter a value in then this value gets added to the list as an item.
However once the value is entered into the list is there a way i can select the item in the list box without having the input box appear??? its really annoying i need to get rid of that input box from appearing when i select an item within the list box but at the same time when i click on the actual list box and not the item itself i would like the input box to appear, how can i achieve this plzzz??
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
List Box Item Scrolling (Next Item)
Hello,
I was wondering what the code would be for a command button to make the next item in the list box be selected?
Kind of like a NEXT button.
EXAMPLE:
List box Line 1
List box Line 2
List box Line 3
List box Line 4
If List box Line 2 is selected then clicking the next button would DESELECT List box Line 2 and SELECT List box Line 3.
If I didn't explain enough just let me know.
Stilekid007
How To Search Listbox For Item If Item Not Found Add Item?
Hi, lol man I cant find nothing today when I search the forum.
This my latest problem, How do I search a listbox for an item lets say "Game Over" And if the item is found the program does nothing, but if the item is not found it will add "Game Over"
Thanks Again
Delete Single Item From History
how could i delete a single file from the internet history?
im looking for a function that would internally find the temp inet files folder rather than using a simple kill function, since i want the code to be flexible if the temp file location changes.
or i need a way to get the location of the temp inet folder so i can send a kill command to the file.
thx for any help
BackColoring Single Listview Item?
ok heres my problem you're all been waiting for since you were born..
Lets say theres a listview control operating in report-mode.
How do I set one single item's back color?
Here's a line which sets the fore color but there's no .BackColor method or is there?
LW.ListItems(1).ListSubItems(1).ForeColor = vbBlue
Found some VB.NET stuff including that method but I'm using VB6 (SP5)...
Combobox Single Item Forecolor
Is it possible to set a single item in a combobox to a different color than all the other items?
- one_eye
Edited by - cyclops_one_eye on 7/9/2004 7:18:27 AM
ListView - Disabling A Single Item
I using the ListView control with checkboxes and two subitems for each item in my program to display a list of applications. I want to display a list of all our current applications in the control, but I only want user to be able to select certain ones (depending on whether he has permissions or not)
Is there a way to disable a single item? Or when the user click on a checkbox for an item I don't what him to select, is there a way to just uncheck the box? I can't find out what the event is when you click on the checkbox.
Thanks for the help,
Jacob
jfunderb@rocketmail.com
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 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 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 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
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 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
------
Copy Single Item From Listbox To Clipboard
I have a form with a listbox with a few listitems and a command button. How can I code my form to highlight a single item, then use the command button to copy the item to the clipboard? Any help is appreciated
Searching Item Using A Single Word Even By A Letter
hey guys, actually this is the 2nd time i'm posted my problem
i want to create a form that functioned as search form
in my case i can run it by type all the name of the item
Private Sub txt_key_change()
If rs_DATABASE.BOF = False Then
rs_DATABASE.MoveFirst
rs_DATABASE.Find "(Item)='" & txt_key.Text & "'"
If rs_DATABASE.EOF = False Then
txt_item_1.Text = rs_DATABASE.Fields(0)
txt_description_1.Text = rs_DATABASE.Fields(8)
Else
txt_item_1.Text = ""
txt_description_1.Text = ""
End If
End If
End Sub
example: when I type "item1" on txt_key, "item_no_1" is appear on txt_item_1 and "bearing" on txt_description_1
actually i want to find a code/syntax that allow me to just type one word then it will appear on the txt_item_1
example: i want to just type "it" then on txt_item_1 it will appear "item_no_1" and so on just like AutoComplete when you type your previous search word on Google.com
can anyone post the code here????
Never Be Afraid Being A Noob, Because Somehow It Will Guide You To A Master
Edited by - auroz vrixxz on 5/6/2008 2:01:08 AM
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.
|