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




Add A List Item To A Loaded Form List


help please. this is probably very simple.

i have a form loaded and showing. i need to add items to a list box, and my code is in a public sub in a different module.

my code follows. i wind up getting an "object doesn't support this type of property..."

i feel like i am close, i just don't seem to be referencing the form list correctly.

thanks much!

Public Sub BuildOverviewList()

Dim dbSOURCE As Database
Dim dbTARGET As Database
Dim rsSOURCE As Recordset
Dim rsTARGET As Recordset
Dim strDatabase As String
Dim strTable As String

strDatabaseName = "ProductCategories.mdb"
strTableName = "tblCurrentPresentation"
Set dbTARGET = OpenDatabase(dbPath & strDatabaseName)
Set rsTARGET = dbTARGET.OpenRecordset(strTableName, dbOpenDynaset)

'aryProductGroup provides the selected categories
For i = 1 To UBound(aryProductGroup)
'aryCategory1
For j = 1 To UBound(aryCategory1)
If aryCategory1(j) = -1 Then
strDatabaseName = "Category1_information.mdb"
strTableName = "CategorySlides"
Set dbSOURCE = OpenDatabase(dbPath & strDatabaseName)
Set rsSOURCE = dbSOURCE.OpenRecordset(strTableName, dbOpenSnapshot)
'write the record to the target table and add to list1
'USE THE ARRAY POSITION (j) TO GET THE SLIDE NAME FROM THE CORRECT TABLE
'ADD THAT SLIDE NAME TO THE LIST.
With rsSOURCE
rsSOURCE.Move (j)
With rsTARGET
.AddNew
![StepID] = 4
![CategoryID] = aryProductGroup(i)
![ProductID] = j
![Name] = rsSOURCE.Fields("SlideName").Value
.Update
End With
'Forms.frmPresOview6.List1.AddItem rsSOURCE.Fields("SlideName").Value
Forms.frmPresOview6.List1.AddItem rsSOURCE.Fields("SlideName").Value
End With
'also add record to ProductCategories/tblCurrentPresentation
End If
Next j

Next i




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Finding List Item As U Typed In Combo Box(Dropdown List Style).
Basically the title say it all.

When I type a letter in combo box it finds item by matching the letter that I typed, but when I type in a second letter it searchs item that starts with the second letter.

I wonder is there a way to macthing list item as u typed in combo box(Dropdown List style).

Thanks in advance.
Joon

Create List Of Files From Folder But Allow Double Click On List Item To Run Bat
I am a newbie
But am making some progress
My next plan is to make a simple dialog with a list box and 3 buttons to do the following
List all the batch files in a folder
then allow me to highlight one item in the list so when I click the button it will run that bat file.

Sounds easy enough but I just keep hitting a brick wall and am not making any progress at all.

All help or similar snipits of code that I can re-organise will be greatfully apperciated.

Thanks in advance

HighLight List Box Selected List Item With User Defined Color
Hi Friends,

I need a help from u all. My problem is to change the Backcolor of the selected listitem of a listbox.

Let me explain detail. Normally in a listbox if we selected the list, the list item will be highlited with blue backgroud (ie. the selected item color settings of the system). Now I need to hightlight the selected list in the list box with my own color say red, green or something else.

Would anyone help me.

V.P. Vijayavel

How To Change Back Color Of List Item In List View
Dear members,

i am having small problem with listview control , I want to assing alternate colors to list items, but i con't,

hope someone will help

regards
D.L.Narayana

ListBox - Move List Item To Place In List
I have a list box with several items. I am trying to make a button that when the user selects an item in the list box, they can click on the button which will move the item up one in the list box:

So if my list looked like this:

ONE
TWO
THREE
FOUR
FIVE

and the user selected FOUR and clicked the button the list would look like this:

ONE
TWO
FOUR
THREE
FIVE


Does anyone know how to do this?

Thanks,
M

Combine List Items To Create New Item In Same List?
Hi all,

This has been giving me fits for a few days - any help would be most appreciated. I'm sure it's pretty simple, but I'm new to VB (and programming in general) and can't seem to come up with the correct syntax to get this to work:

I have a listbox from which the user can select mutliple items. Once user performs a multi-select, I enable a button (no problem there). When user clicks that button, I want to create a new item in that same list consisting of all selected items with "AND" between them.

Thus, if user had selected <item 1>, <item 2>, and <item 4>, the new item would be "<item 1> AND <item 2> AND <item 4>". Can someone please help me with the logic and syntax on this?

Here's what I have up to this point (I've removed the parts that I believe - based on the fact that this is not working - to be wrong and replaced them with ?????):

Code:
        Dim terms As String
        For Each terms In List.SelectedItems
            If List.SelectedItems.Count > 1 Then
                terms = ??????? & " AND " & ???????
            End If
        Next
        List.Items.Add (???????)


Thanks!!



Edited by - troy_atl on 10/17/2005 12:04:26 PM

Change Background /Forgroound Of Each List Item In A List Box
How would i be able to change the back color of a listitem in a list control ? For example i want item number 1 to have a red background item number 2 to have a blue background etc.
Thanks for the help

Jerry

Remove Item Form List And File...
hi there,

i can remove an item from a listbox with this code:


PHP Code:




Dim x As Integer

List1.RemoveItem (List1.ListIndex)
List1.Refresh
MsgBox (List1.Text)
Open "\ocp0nt1softmet$ estapplog.txt" For Output As #1
For x = 0 To List1.ListCount - 1
    Print #1, List1.List(x)
Next x
Close #1







But i can't get the selected item into a string. I want this cause i have to rewrite this string and put it back, like an correction...

plz help

Getting A Combo Box List And Putting It In A List Box List On Another Form
I am finally writing my first MDI! I'm doing a lot better than I thought I would so far, but now I'm stuck. I need to have a list from a combo box copied into a list box on another form. I want it in the Form_Load() event. Right now I have:

Code:Private Sub Form_Load()
frmpresetedit.deletepreset.List = frmtimer1.cmbpresets.List
frmpresetedit.Show
End Sub

deletepreset is the list box, cmbpresets is my combo box.
It always comes up with a compile error at the .list part of cmbpresets.list and says that 'the argument is not optional'. What is my problem here? I'm sure this problem is simple and I'm probably just making a stupid mistake. What code do I need to use?
Thanks


Now, don't get me wrong, 'cause baseball's a great sport.
It teaches little children simple eye-hand coordination with little effort or exhaustion.

 -byufan

Edited by - byufan on 7/20/2004 4:20:57 PM

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

Getting A List Of Loaded Dlls
Hi guys.

I've trawled the web and I can't find anything on getting a list of dlls loaded in a VB6 app. Does anyone have any pointers?

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 Loaded Modules / References
I'm looking for a way to list all available modules loaded into memory using VB 6.

The specific items that I am trying to list are for example OCX's, DLL's, TLB's and EXE's.

I would like to be able to list items in the same way as the "Available References" are listed when selecting the "Project" menu option "References..." in VB.

Thanks in advance for any assistance.

WCBH

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

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

Last List Box Item
I have a list box that is filled dynamically and I don't know in advance how many items it will contain. How can I get the last item value? Here is what I tried:

Code:
lstBibPlace.Index(lstBibPlace.ListCount - 1)
but that generated a 'wrong number of arguments' error message.

Thanks!

List Item I
I have a loop here for saving a list's contents. i want the i item of the list. how can i take that? and as soon as i save i want to store the i item read from the file put into the list. how can i do that too? thanks anyway for any answers....

Add Item To List Box
Hi,
Below is the code im using to sort a file into a list box.
Only thing is though im putting it into a rich text box first.
When i do this the file is to big and so when it goes to sort it i get an overflow error.

How can i chnage this code so it dosent go through the right text box and gets sorted into the list box straight away.


Code:
otext = Display.Text
mtext = Replace (otext , Chr$(0) , " ")

Display.Text = mtext

Dim Count As Integer
Count = 0

Dim sentence As String
sentence = "the fat cat eats fork.txd from the can"

Dim words() As String
words = Split(sentence) ' Split up the sentence into words

Dim i As Integer

For i = 0 To UBound(words) ' Loop through each word
Dim word As String ' Set the word to a variable
word = words(i)

If Right$(word, 4) = ".txd" Then ' If the word ends in .txd
Count = Count + 1
List1.AddItem Count & ": " & word
End If
Next i

Thanks for any help.
-Dave

Add An Item To List 6
I would like to add an item to list 6 after pressing a button.

the item simply and always says End of Search. Can anyone tell me how to do this?

Also I have a timer8 and it counts in seconds. Is there a way that when the button is pressed, the timer is enabled and starts to count, and as each second goes on, a labeltime.caption number is increased by one. And when the list 6 gets the end of search item added to it, the timer is disabled? thanks!

Add An Item In A List Box
I have a list box and i am trying to add elements as follows

ns = 4
Dim temp As String
For x = 1 To ns - 1
temp = "Stage " + x + " Oulet"

List1.AddItem temp, List1.ListCount
Next

Basically i would like the items in the list box to appear as follows:

Stage 1 Outlet
Stage 2 Outlet
Stage 3 Outlet
etc

A mismatch error comes up when i try to this!
I tried to change the + x + part of the expression to
+String(x) +
But this did no work either!

Please help !!!

List Box Item
I have to list box. If i add an item from list1 to list2 and the item already exists a beep sound

But how can i change the color of that item in list2 and make it blink?

Going To Next Item In List??
ok, here's a tricky one. Say I have 3 filenames in a listbox. when the user double-clicks on the file, my program calls on the Shellexecute API call to open the file with it's default program. ok say for example these are *.wav files. When the first file in the list is finished playing I want the program to automatically go to the next file in the list and use shellexecute to open it. So my question is: How can I get my program to recognize when the playing file has finished playing? Any suggestions, tips, flames, etc. appreciated. Thanks

-Jeremy

Last Item In A List Box
How do I go about getting the last item in a list box?


-Thanks

Last Item In List Box Seems To Be 0
Hi there
I have a listbox with checkboxes

I am looping through the selected items but it seems that it always makes the last item 0

CODE    Dim n As Long
    With courselist
    For n = 0 To .lst_files.ListCount - 1
        If .lst_files.Selected(n) = True And .lst_files.List(n) <> "" Then
            MsgBox (.lst_files.List(n))
        End If
    Next
    End With

Get Item From The List Box
Hi! Can you please help me on how to get the item from the list box... like if i click one of the item from the list box, i want it to be shown in a text box but i dont know how to do it. i have tried to set it by using adodc but the problem is i only get the first item and no more. Thanks a lot!!!

Next Item In List
I want to make it so that when i click a button(command1) it makes the listbox (list1) select the next selection in it. So everytime i click the button the selection moves down one. Can someone please help?

Help With File List , Dir List And Drive List Boxes..
How do i link my drive list , file list and dir list boxes to gether , so that when i for exaple set the drive list to c: , the dir list will then give all dir in there, and file list will show me files from the directory, right now the default file list is set to my vb file list and i cant change it...

Installed Item In The List
Disclaimer: Admins, leaders, since i think that the answer to my question has something to do with the Registry, i posted it here. There is no intension of violation of any rules OK.

When we install something with a commercial installer or any other installer, an item representing what we installed appears in the "AddRemove Programs" list in the control panel. What does the installer program do the get it on that list?

I am curious and desparate. I cant stand the fuss that installer programs make to install even one or two files that i decided to make one myself!

Adding An Item To A List Box
I am currently working on a project with college and want to add items chosen from a combo box to a listbox along side it. I am using Access to create the Database.

However, when I come to enter the following code, the syntax isn't correct. I have a feeling it may be because i'm using VBA as opposed to VB6 and I know that some of the coding is slightly different. Below is the code I am using to add them.


Code:
lstCoursesTaught.AddItem "Computing"
However, the VB Editor doesn't recognise the .AddItem section. It only displays .AddColon. Can anybody help me with this problem?

Thank you

Combo Box, Item Not On List
Hi,

How can I prevent the message " Item does not exist on the list" from appearing? I am using the not-in-list event to perform a procedure and I only want my message to appear. Using Docmd.CancelEvent has not helped me. Any suggestiong?

Thanks

How Can I Save The Item In The List Box?
I use this code to add item into listbox and remove item into listbox


Code:
ListBox2.AddItem TextBox1.Text
ListBox2.ListIndex = ListBox2.ListCount - 1

ListBox2.RemoveItem ListBox2.ListIndex
ListBox2.ListIndex = ListBox2.ListCount - 1
But after I add the item the workbook doesn't save the item ao I try this code


Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Litbox2.Text
End Sub
But it doesn't success

How can I save the item in the list box?

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?

List View Item
what's wrong with the following

dim itemx as listitem

in the sub I have

Set itemX = lvwMails.ListItems.Add(, msgmr,mydate)

gives me error 13

Xth Data Item From A List?
Here's what I'd like to do:

I have an array of data (e.g. Monthly Shipping Costs by Month by Customer). I will also have a sum of shipping costs by customer.

I could easily sort this array by month to get the top 10 Customers by Total Shipping Cost. However, since I won't necessarily have control of this workbook, I don't want to have to do that.

I'd like to be able to show the Top 10 list even when the data changes.

For example, I could use the Large function to get the #1, #2, #n item for costs, but then how do I translate that back to a customer? I can't use the LOOKUP functions (as far as I know) because, if there's a tie, then it wouldn't return the proper customer (i.e. if Custer X and Customer Y both had $5,000 total shipping costs, how would I return the second one?). Also, the Large function returns an error if there's a tie.

Hmmmm... I'm thinking that I may need to use a VBA function for this, but I was hoping to get around that.

Does anyone have any ideas without using VBA?

How To Check If A List Box Already Contains An Item
i have a form containing a dir and file control and a listbox control and ther user has to click an add button to add files from the file control into the listbox. but i dont want to allow multiple enteries of the same file. how would i check if a file has already been entered and alert the user ?


-Pendaz

If Item In A List Is Not Selected
Hi All,

How can I do a test to see if there has been any items in a list selected. ie. if there has not been an item selected show a message box, else form2.show.

Thanks

Loftty

Checking Each Item In The List Box In DB
Hi,

Lets say i have items in a listbox

listb
-----
a
b
c
d

I have to get each value from the list and check whether these value is in sybase table and return the respective values from the table. Can anyone help me with this.

I am lost

Thanks in advance

Rename A List Item
I'm trying to create an irc client and i'm currently at the change nick event... my problem is the following:
i succed to change the nick in the listbox but i want him to be sorted (he remains in the same position as the previous one).
initialy the list.sorted is set to true and after i rename it i try to refresh it but still nothing... what should i do?

List Box Remove Item
Ok i need to remove a list box line when it is selected and then when i hit a command button it removes it as well as the same line in the other list boxes. The list boxes are in an array.

Can I Add A Hidden Value To A List Item?
im pulling a list from a database, and adding it to a listbox. is there any way to add a hidden value per item in the listbox? i want to add the autonumber from the database.

the other option i have is having another listbox behind it, then when you click on list1.list(1) it will also read from list2.list(1)... only problem is i want list1 to be sorted and i can't keep them parallel that way.

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

Removing Item From List Box
I have a list box which contains several records, I want to be able to highlight one of the records in the list box and click on a command button to remove it.

Does anyone know the code to go behind the button??? I know you need .RemoveItem cuase ive tried that and ive got it to delete a record in a certain index position however I need to delete the one selected.

Thanks.

List Font Per Item
Is it possible to set a font for just 1 item in a list?
I only seem to set the font and styles for the WHOLE list.

Here's some code:

Code:
....
....
Do Until .EOF

If status = True Then

'SET FONT HERE
List1.AddItem .Fields("functionName")
List1.ItemData(List1.NewIndex) = .Fields("projectID")

Else

'Normal Font
List1.AddItem .Fields("functionName")
List1.ItemData(List1.NewIndex) = .Fields("projectID")

End If
.MoveNext
Loop
....
....
This is how i want it to appear:

name1
name2
name3
name4
name5
name6
name7
name8

Removing Item From List
I have a list box and I want to remove one of the items in the list box. I know that the item is "index.htm" but I don't know which row it is in. How would i go about deleting whatever row has the data "index.htm" ?

Add An Item To The Datacombo List?
I have a datacombo box 'state' bounded with a datasource. User can select a state from the list. I want to add an item says '--Select a State--' on the top of the list and validate if user doesn't select any.

How can I add this item to the top the datacombo list?

Choosing Item From List
I have a list that has some choices in it. Just for the example let's say 3 things to choose from.

Basically i want my code to choose the first item in the list

run code

and if it returns a false value

choose the second option on the list

and so on until it find a true value.

i hope this is enough info to get started on some help

Removing An Item In A List Box..
I am trying to remove the Item in text7.Text from List2
here is what I have tried.


Private Sub Command7_Click()
If Text7.Text = List2.Text Then
List2.RemoveItem List2.ListIndex
End If
End Sub

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

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