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




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




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Solved-howto Send First Item Of Listbox Totextbox, Then Delete First Item Of Listbox?
Lol another question, how do you do this

how to send first item of listbox to textbox, then delete first item of listbox?

Thanks

Removing An Item From A ListBox By Clicking The Item
Hi, How do you remove an item from a ListBox by simply clicking the item u want to be removed?

This is the code i tried but it doesnt work:

Private Sub list1_Click()
Dim n As Long
Dim ncount As Long

ncount = List1.ListCount - 0
For n = 0 To ncount
List1.RemoveItem (n)
Next
End Sub

Any ideas?


-Flaw

Using An Inputbox To Search DB For An Item Then Once Records Are Found Send To Data Report
I am using ADODB to connect and manipulate a DB. What I am trying to do is write code so that a user can enter any text into an input box. Then I want to search my DB and try to find the records from the text inserted by the input box. When the records are found I want to send them to data report. Is this possible?

Search Multiline Textbox And Retrive Text From The Line After Found Item?
i was wondering if anyone could help me, i am building some makeshift software for my work to improve productivity, i want to make a new fuction to search a textbox (multilined) for a specific set of Text, EG john, smith


if finds john, smith and then copys the line of text it is on and the line after it to a String so i can move it about to wherever i want.

any feedback would help alot.

Search Item In A Listbox
is it possible to search a keyword in the listview. if a user enter some text in a text box to search a item in the list it should focus on that item. pls help

How Can I Search For An Item In A Listbox With A Textbox???
I want to make a search in a listbox with a textbox, similar to the one in windows help where it scrolls down to the closest match as you type in what you want to find.

Change ListBox Item Text?+ Change Item Color Or Status?
hi
I'm new to VB. I want to change the text of a ListBox item.
I used AddItem to add items.
Then I tried to change a selected item using lst.Text = "somethingNew", but it doesn't work...
Pl. help

And need to know.. how to change the color of an item or status(disable) of an item???

Thanks

Search A Listbox For A String Before Adding Item
I have a listbox, and the user can add items to it by entering text into a textbox and clicking a label. Before an item is added though, I want to check to see if it already exists.

Declarations:
Code:
Private Const LB_FINDSTRING = &H18F
Private Const LB_FINDSTRINGEXACT = &H1A2
Private Declare Function SendMessageString Lib "User32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long


Label Click:
Code:

Dim Index As Long
Dim Find As String
Dim I As Integer
For I = 0 To List1.ListCount - 1
    List1.Selected(I) = True
    Find = List1.Text
    Index = SendMessageString(List1.hWnd, LB_FINDSTRINGEXACT, -1, Find)
If Index > -1 Then
    List1.ListIndex = Index
Exit Sub
End If
Next
    List1.AddItem (TXTList.Text)


The problem is, after I have added my first item it will not let me add anymore because it exits the sub as it has found a match, when really there is no match to find.











Edited by - Rapidfire on 4/29/2007 12:46:12 PM

String Index/listbox Item Search [fixed]
hey...

I have a listbox with some items in it, where i have added (O) infront on some items.... what i want is, to remove (O) again from the item, i tryed coping it into a string, but then i forgot how i check the first 3 letters of the string...

can someone help plz ?

Take care and have fun

Garn

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

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

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

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

Array Handling, Adding Item, Deleting Item
Hello,

I was going to build a "buffer" and thought array would be a suitable way.
when the form loads the ArrayStart is set to 0

when data is coming in it is added to the array:

MyArray(ArrayStart)= data
ArrayStart= ArrayStart + 1


Now i would like to find out whether there is any data in this array
if there is im doing something with that data

but then i would like to simply delete that data from the array

how do do this?

Pointing Mouse At Some Item On Form Causes Info About This Item To Appear???can This
my question is that when you point the mouse at some item on the form you get some info about this item to appear, like on html page or for example when you point to the message icons in vbforum page like the lightbulb symbol it tells you that it is a lightbulb...can this be done in visual basic....

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

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

Ken

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

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

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

Item Cannot Be Found
Hi,

I keep getting the following error when I get to the second line of the code beneath...
Item cannot be found in the collection corresponding to the requested name or ordinal.

sSQL = "EXEC sp_SaveCapex " params listed.
Set rsProposalNo = g_Conn.Execute(sSQL)
g_iProposalNo = rsProposalNo.Fields("Record")

CREATE PROCEDURE sp_SaveCapex
(
    Params
)
AS
INSERT INTO CAPEX
(
        Columns listed
)
VALUES
(
    Values listed
)

SELECT @@identity AS Record
GO

The insert works fine and if I run the stored proc in query analyzer, it returns the value I require. However, when I run it in VB I get the error.

Anyone know what's going on?

Thanks for any help,
Robin


Item Can't Be Found
Hi you all... I trust today finds you healthy and happy. I have an application that seems to be giving me a bit of trouble. I hope someone can help me out.

Code:
Private Sub cmdTask_Click()

    Dim adoCon As ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim sSQL As String
    Dim strPath As String

    
    Set adoCon = New ADODB.Connection
    Set rs = New ADODB.Recordset
    
    strPath = "C:Program FilesCommon FilesLibrary"
    
    With adoCon
        .Provider = "Microsoft.jet.oledb.4.0"
        .ConnectionString = "Data source=" & strPath & "Library.mdb"
        .Open
    End With
    
    If cmdTask.Caption = "&Submit" Then
        sSQL = ""
        sSQL = sSQL & " INSERT INTO Library (Name_of_Authoror, Title_of_Book,"
        sSQL = sSQL & " Date_of_Publication, Name_of_Publisher)"
        sSQL = sSQL & " Values ('" & cmbAuth.Text & "', '" & cmbTitle.Text & "',"
        sSQL = sSQL & " '" & txtDate.Text & "', '" & txtPub.Text & "')"
    
        adoCon.Execute sSQL
    
        cmbAuth.Text = ""
        cmbTitle.Text = ""
        txtDate.Text = ""
        txtPub.Text = ""
    
    ElseIf cmdTask.Caption = "Searc&h" Then
        If optTitle.Value = True Then
            sSQL = ""
            sSQL = sSQL & " SELECT Title_of_Book, Date_of_Publication, "
            sSQL = sSQL & " Name_of_Publisher"
            sSQL = sSQL & " FROM Library"
            sSQL = sSQL & " WHERE Name_of_Author = '" & cmbAuth.Text & "' "
            sSQL = sSQL & " Order By Name_of_Author Desc"
        ElseIf optAuth.Value = True Then
            sSQL = ""
            sSQL = sSQL & " SELECT Name_of_Author, Date_of_Publication, "
            sSQL = sSQL & " Name_of_Publisher"
            sSQL = SsSQL & " FROM Library "
            sSQL = sSQL & " WHERE Title_of_Book = '" & cmbTitle.Text & "' "
            sSQL = sSQL & " ORDER BY Title_of_Book Desc"
        End If
    End If
        
    Debug.Print sSQL
      
    With rs
        .CursorType = adOpenStatic
        .CursorLocation = adUseClient
        .ActiveConnection = adoCon
        .Open sSQL
         Set .ActiveConnection = Nothing
    End With

    If rs.RecordCount = 0 Then
        If rs.EOF Then
            With frmBoblib
                .txtDate.Text = ""
                .txtPub.Text = ""
            End With
        End If

    ElseIf rs.RecordCount = 1 Then
        If Not rs.EOF Then
            With frmBoblib
+++++++++++++++++++++++++++++++++++++++++++++++
                .txtDate.Text = rs.Fields(Date_of_Publication).Value
+++++++++++++++++++++++++++++++++++++++++++++++
                .txtPub.Text = rs.Fields(Name_of_Publisher).Value
            End With
        End If
        
    ElseIf rs.RecordCount > 1 Then
        If Not rs.EOF Then
            With frmBoblib
                .txtDate.Text = ""
                .txtPub.Text = ""
            End With
        End If
    End If
    
    With rs
        .CursorType = adOpenStatic
        .CursorLocation = adUseClient
        .ActiveConnection = adoCon
         Set .ActiveConnection = Nothing
    End With


    End Sub


In the above code, when I run the search operation, I get the error, "Item cannot be found in the collection corresponding to the requested name or ordinal". The line erring seems to be the line I have marked with the "+" signs, but I cannot see anything wrong with that line. Can someone give me another look... another set of eyes never hurts.

Thank you so much for your help,


Happieman
a.k.a. Bill

Edited by - Happieman on 9/9/2005 11:43:12 AM

Item Not Found In This Collection
I get this error message, "Item not found in this collection"
and this line of code is marked
(code)
Set FagIStudieØkten = Databasen.OpenRecordset("SELECT StudieØktPlanFag.***, StudieØktPlanFag.StudieØktPlanNr From StudieØktPlanFag WHERE (((StudieØktPlanFag.StudieØktPlanNr) = " & FinnStudieØktPlan("studieøktplanNr") & "));")
(/code)


And that is logical, because there are no items in that table, but why is VB giving me an error message just because there are no
items, I did not request any items. The sole purpose of the sql-sentence was to check if there was any?!

Item Cannot Be Found In The Collection..
Hello all. I've got a problem with a class module sub where I am trying to supply a value to a parameterized query in the text for a command. It seems like the command does not have the parameter added to the collection like it should be doing. I know it's got to be something simple that I just can't see. Any ideas????

Thanks...code sample below..
Public Sub GetWorkAreaDescription()
Dim rsDesc As Recordset
MsgBox "cmd is " & mcmdDesc.CommandText
mcmdDesc.Parameters(0) = msWorkArea
'This is the line with the problem. Item cannot be
found in the collection...
Set rsDesc = mcmdDesc.Execute
msDescription = rsDesc!Description
End Sub

Query Item Cannot Be Found
For reference, this works great in the query statement. The problem is with the code referencing the query statement. I can even paste the debug print right back in to the sql in the query and get the desired results.

But when running this way, I get the following:
Runtime Error 3265
Item cannot be found in the collection corresponding to the requested name or ordinal.

Any ideas would be greatly appreciated.

' *********************************************************
' Update Rel By / Rel Date Information on BOM for new parts

Dim rsBOM As ADODB.Recordset
Set rsBOM = New ADODB.Recordset

Dim sqlBOM As String

sqlBOM = "SELECT DISTINCT tblECOList.PartNo, " & _
"tblBOM.PartNo, " & _
"tblBOM.JobNo, " & _
"tblECOList.ECORefNum, " & _
"tblECOList.NewPart, " & _
"tblBOM.ReleasedBy, " & _
"tblBOM.ReleasedDate, " & _
"tblPartsListing.Code " & _
"FROM tblPartsListing INNER JOIN (tblBOM INNER JOIN tblECOList ON tblBOM.PartNo = tblECOList.PartNo) ON " & _
"(tblPartsListing.PartNo = tblBOM.PartNo) AND (tblPartsListing.PartNo = tblECOList.PartNo) " & _
"WHERE (((tblBOM.JobNo)=99999) AND " & _
"((tblECOList.ECORefNum)=2276) AND " & _
"((tblECOList.NewPart)=True) AND " & _
"(isnull(tblBOM.ReleasedBy)) AND " & _
"(isnull(tblBOM.ReleasedDate)) AND " & _
"((tblPartsListing.Code)=" & Chr(34) & "Purchased" & Chr(34) & " Or " & _
"(tblPartsListing.Code)=" & Chr(34) & "Purchased-Elec Comp" & Chr(34) & " Or " & _
"(tblPartsListing.Code)=" & Chr(34) & "Purchased-Mech Comp" & Chr(34) & " Or " & _
"(tblPartsListing.Code)=" & Chr(34) & "Purchased-Major Comp" & Chr(34) & " Or " & _
"(tblPartsListing.Code)=" & Chr(34) & "Stock" & Chr(34) & "));"

Debug.Print sqlBOM

rsBOM.Open sqlBOM, CurrentProject.Connection, adOpenDynamic, adLockOptimistic
rsBOM.MoveFirst

Do While Not rsBOM.EOF
MsgBox rsBOM.Fields!PartNo
rsBOM.Fields!ReleasedBy = EmployeeINIT
rsBOM.Fields!ReleasedDate = Date
rsBOM.Update
rsBOM.MoveNext

Loop

rsBOM.Close
Set rsBOM = Nothing

Item Cannot Be Found Error
Why is it that Im getting this error? Item cannot be found in the collection
corresponding to the requested name or ordinal
Below are my codes.

On Form_load:

Code:
Private Sub Form_Load()
Call openConnection
Me.Left = LeftPos - 200
Me.Top = TopPos - 200

Set rsStockOut = New ADODB.Recordset
Set rsClient = New ADODB.Recordset
rsStockOut.CursorLocation = adUseClient

sSQL = "SELECT tblStockMasterFile.ProductID, " & _
"tblStockMasterFile.ProductName, " & _
"tblStockMasterFile.Unit, " & _
"tblStockMasterFile.ReOrderPoint, " & _
"tblStockTransFile.EntryDate, " & _
"tblStockTransFile.pSequence, " & _
"tblStockTransFile.PurchasePrice, " & _
"tblStockTransFile.Quantity, " & _
"tblStockTransFile.Reason, " & _
"tblClientMasterFile.ClientName, " & _
"tblClientMasterFile.ClientCode , " & _
"tblClientMasterFile.Budget " & _
"FROM tblClientMasterFile INNER JOIN " & _
"tblStockTransFile ON " & _
"tblClientMasterFile.ClientCode = tblStockTransFile.ClientCode INNER JOIN " &

_
"tblStockMasterFile ON " & _
"tblStockTransFile.ProductID = tblStockMasterFile.ProductID"

If rsStockOut.State = adStateOpen Then rsStockOut.Close
rsStockOut.Open sSQL, oConn, adOpenStatic, adLockOptimistic

Call FillcboClient
Call LockFunction(frmStockOut, "TextBox")
lstStockOut.Enabled = False
End Sub 'Form_Load


The Function FillcboClient:

Code:
Private Sub FillcboClient()
cboClientName.Clear
cboClientName.AddItem "- Type or Select -"

'TODO : Fill cboAuthorID
'-------------------------------------------------------------------------------------
sSQL = "SELECT ClientCode, ClientName FROM tblClientMasterFile"
'this what i mean for 1 trip..u open the rs just one time

If rsClient.State = adStateOpen Then rsClient.Close
rsClient.Open sSQL, oConn, adOpenStatic, adLockOptimistic

If Not rsClient.BOF And Not rsClient.EOF Then
rsClient.MoveFirst

While rsClient.EOF = False
cboClientName.AddItem rsClient("ClientName").Value
rsClient.MoveNext
Wend
cboClientName.ListIndex = 0
End If
'-------------------------------------------------------------------------------------
End Sub


Product ID Change event:

Code:
Private Sub txtProdID_Change()
txtProdQtyOut.Text = ""

'Use for Barcode reader
' If InStr(1, txtProdID.Text, "*") = Len(txtProdID.Text) Then
' txtProdQty.SetFocus
' End If

If rsStockOut.State = adStateOpen Then rsStockOut.Close

On Error Resume Next
If txtProdID.Text <> "" Then
rsStockOut.Open "SELECT * FROM tblStockMasterFile WHERE ProductID = '" & txtProdID.Text

& "'", oConn, adOpenStatic, adLockOptimistic

If rsStockOut.RecordCount <> 0 Then
txtSupply.Text = rsStockOut.Fields("Quantity")
txtProdName.Text = rsStockOut.Fields("ProductName")
Else
'txtSupply.Text = ""
txtProdName.Text = ""
End If
Else
txtSupply.Text = ""
txtProdName.Text = ""
End If
End Sub 'txtProdID_Change


The cboClientName Change event: The call ReplaceQuotation Function is not working here but in my other forms the same code is perfectly working.

Code:
Private Sub cboClientName_Change()
txtClientCode.Text = ""

'if user click this..then search for the appropriate record then _
display the Client Code in the textbox
sSQL = "SELECT ClientCode, ClientName FROM tblClientMasterFile " & _
"WHERE ClientName='" & cboClientName.Text & "'"

If rsClient.State = adStateOpen Then rsClient.Close
rsClient.Open sSQL, oConn, adOpenStatic, adLockOptimistic
' Call ReplaceQuotation(cboClientName)

'display the Client Code in the textbox
If rsClient.BOF = False And rsClient.EOF = False Then
txtClientCode = rsClient.Fields("ClientCode").Value
End If
End Sub 'cboClientName_Change


The Add Button: the highlighted parts is where the error points.

Code:
Private Sub cmdAddItem_Click()
Dim lst As ListItem

If txtProdID.Locked = True Then
txtProdID.Locked = False
End If 'txtProdID lock

If lstStockOut.Enabled = False Then
lstStockOut.Enabled = True
End If

If CheckNullValue = False Then Exit Sub

Set lst = lstStockOut.ListItems.Add(, , txtProdID.Text) 'DISPLY IN LISTVIEW
lst.SubItems(1) = txtProdName.Text
lst.SubItems(2) = txtProdQtyOut.Text
lst.SubItems(3) = Format$(rsStockOut.Fields("PurchasePrice"), "###,###,##0.00") 'Capital
lst.SubItems(4) = Format$(lst.SubItems(3) * 1.15, "###,###,##0.00") 'Selling Price
lst.SubItems(5) = Format(lst.SubItems(2) * lst.SubItems(4), "###,###,##0.00") 'Total

txtProdID.Text = ""
txtProdQtyOut.Text = ""
txtProdID.SetFocus

Set lst = Nothing 'destroy the list
End Sub 'cmdAddItem_Click

Can someone please tell me what am i missing here?
I have attached here my table relationships
Any help is much appreaciated and thank you very much in advance.

Item Not Found In This Collection
I get error 3265 - Item not found in this collection when the following bit of code runs. The weird thing is, the field does exist. This is on an access databse. Any ideas what else could be causing this?

Thanks.



VB Code:
Data1.RecordSource = "user_settings"    Data1.Refresh     If IsNull(Data1.Recordset("userid")) Or Data1.Recordset("userid") = "" Then       MsgBox "No userid has been supplied."    Else       sUserid = Data1.Recordset("userid")    End If

Item Not Found In This Connection
I need help with the following code. I just added pallet fields in the table. I have a form which pulls up information from prior like orders. I need to add a SQL that brings up the new pallet fields from the table which they are present. When the second SQL is ran I get a "Item not found in this connection" error. Any help would be greatly appreciated. Thanks,

strSQL = "SELECT Packaging,ESTHours,[Order#ID] " & _
             "FROM [Production Schedule] " & _
             "WHERE CustomerNo = '" & Trim(rs("CUSTOMER_NUMBER")) & "' " & _
             "AND Compound = '" & strCompound & "' " & _
             "AND Color = '" & strColor & "' " & _
             "AND Mapics = '" & strMapics & "' " & _
             "AND Packaging IS NOT NULL " & _
             "ORDER BY [Order#ID] DESC"
             
         Set dbs = CurrentDb
          Set rs = dbs.OpenRecordset(strSQL)
          
           
          If Not rs.EOF Then
          
                        Form.Packaging.Value = rs("Packaging")
                            Form.EstHours.Value = rs("ESTHours")
                                   End If
       strSQL = "SELECT PalletQuanity,PalletWidth,PalletLength,PalletHeight,Surface,[Order#ID] " & _
             "FROM [Production Schedule] " & _
             "WHERE CustomerNo = '" & Trim(rs("CUSTOMER_NUMBER")) & "' " & _
             "AND Compound = '" & strCompound & "' " & _
             "AND Color = '" & strColor & "' " & _
             "AND Mapics = '" & strMapics & "' " & _
             "AND PalletQuanity IS NOT NULL "

         
           Set dbs = CurrentDb
    Set rs = dbs.OpenRecordset(strSQL)

    If Not rs.EOF Then
                            Form.PalletQuanity.Value = rs("PalletQuanity")
                             Form.PalletWidth.Value = rs("PalletWidth")
                              Form.PalletLength.Value = rs("PalletLength")
                               Form.PalletHeight.Value = rs("PalletHeight")
                              Form.Surface.Value = rs("Surface")
                                        End If

Item Cannot Be Found...Error
I get this error
Item cannot not be found in the collection corresponding to the requested name or ordinal.

I know that it supposed to mean that the field doesn't exist in my table...but it does...I copy and pasted the name and I rechecked and it's the same name,
After that I checked if I had record in this field. I do...So How can I solve my problem? I just want to add two item in my combo box.
Thanks in advance.
This is my code
    
Set RsQuotTemp = MyConn.Execute("select distinct noquotation from Tblquotation where nocustomer = " & Me.MSFGCustomer.text)
    If Not RsQuotTemp.EOF Then
    MsgBox (RsQuotTemp("QuotationLabel"))
                                       
      While Not RsQuotTemp.EOF
        Me.CmbQuotations.AddItem (RsQuotTemp("NoQuotation") & " / " & RsQuotTemp("QuotationLabel")) 'Ajoute les Quotations creer par ce client dans le combo box
        RsQuotTemp.MoveNext
      Wend

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 Have X Item Per Page But With Item &lt; X Data
i have crystal report with group by id
can i have 12 item each id each page
in this case i have id which have <12 item
but i want each id have 12 item and if they have <12 item give blank to other until have 12 item each id
thanks alot




Edited by - albantani on 3/22/2005 5:20:56 PM

Search Listbox For Texbox Item, And Add All Items To Another Texbox? (Solved)
Well, this what I am trying to do i want to search a listbox for a keyword which I write on a textbox, and all the items which contain that keyword will be added to another box

Now I have this code that works perfect if I put it in a command button


VB Code:
Dim i As Long, i2 As LongDim tmpStr As String     tmpStr = Trim(Text14.Text)        i2 = List1.ListCount - 1        'In case of Listcount bug    If i2 < -1 Then        i2 = 40000        On Error Resume Next    End If        For i = CLng(CmdSearch.Tag) + 1 To i2        If InStr(1, UCase(List1.List(i)), UCase(tmpStr)) > 0 Then            List1.Selected(i) = True            Text15 = Text15 + ", " + List1.Text            If i < i2 Then Label2.Caption = "Next"            CmdSearch.Tag = i            If i = i2 Then Exit For            Exit Sub        End If    Next    Text14 = ""    Label2.Caption = "Finish"


But the problem is that my program will be use in a remote machine so I can be there to click that button I was wondering if that code can be made into a sub so I can just use a code as such


VB Code:
Call Search


I try it it dint work, anyways any help be appreciated, olso if there another way to do it please tell me how.

Thanks

Error 3265: Item Not Found
Hi,

this is my code

set rsQuery = new ADODB.RecordSet
rsQuery.Open "SELECT person.*, book.* FROM persons, books WHERE person.id
= book.id",db, adOpenDynamic, adLockOptimistic
rsQuery.MoveLast
y = rsQuery.RecordCount
rsQuery.AddNew
rsQuery!id = y + 1
rsQuery!name = txtName
...
rsQuery.Update
rsQuery.Requery

But then the error 3265 occurs saying he can't find "rsQuery!id".
How do I solve this and why do I get this error in the first place?
Because the 2 id's have the same name?

Greetingzzz
Snowball

Item Cannot Be Found In The Collection Error...
Hello,

I am using a recordset to access an Oracle database. I am querying only one, but rather large, table with this query->

SELECT (TO_DATE(ENV_DATE, 'YYYY-MM-DD')), ENVNODE FROM ROBOT_LOG WHERE ENV_DATE = '" & myDate & "'"

The ENV_DATE field in Oracle is defined as CHAR, and myDate variable is CDate'd before I run the query.

When I run this query from VB, it gives me the 'Item cannot be found in the collection corresponding to the requested name or ordinal'.

But ~ When I run this query through the Oracle client Tester I have installed, it works!

I am perplexed. Any ideas?

Daud.

Item Cannot Be Found In The Requested Name Or Ordinal
Hi
I am using Access with VB6.
rs2.Open "Select * from Btest inner Join Bintervallist on Btest.BID=Bintervallist.BID where Btest.BID=14", cn, adOpenKeyset, adLockPessimistic

when i try to write:
ninterval=rs2.Fields(BIntID) Then a message:
"Item cannot be found in the requested name or ordinal"

BIntID is a field inside Bintervallist

thanks in advance

Item Cannot Be Found In The Collection Corresponding To The Request Name..
when i add entries to the database i use this code:

If WorkRS.EOF Then WorkRS.AddNew

For i = 0 To Text1.UBound

If Text1(i).Text = "" Then
WorkRS.Fields(i) = ""
Else
WorkRS.Fields(i) = Text1(i).Text
End If

Next i

WorkRS.Update

This code process until it reaches index 7 then i get the error.
Since i am using workRS.Fields(i) and Text1(i).text, i shouldnt be getting an error where it cannot find a field or there is a mis-spelling...is this true????

Error 3265 - Item Cannot Be Found
When trying to read a field from a DB and the field does not exist, I get error 3265 (item cannot) be found.

Is their any way to know what field is trying to be looked up (without setting a var. before each field read with the name of the field I'm going to look up)?

When updating DB's it is easy to miss or miss spell a field, and it's very hard to find what field is missing or wrong.

Any help would be great.

Thanks Derek

3625 : Item Not Found In Collection...
Set UserDB = DBEngine.Workspaces(1).OpenDatabase(App.Path + "Users.mdb")

In the above code, I get the error "Item not found in collection." Now, I have used this same code with different databases several times. I have done the exact same with this as I have with the others. And ideas?

Item Not Found In This Collection , Any Clue Please?
hi everyone...

i have this form which includes these text fields : fileNo, Date, Send, SendTo, RefNo , StaffName etc...

when i use the next button to see the next record i get this message error :
item not found in this collection

when i debug it i get the error in this line of code:
If IsNull(rs!RefNo) Then txtRefNo = "" Else txtRefNo = rs!RefNo

and in my table i identified reference number as RefNo
i can't see where the error is , any help please?


Code:

Private Sub nextcmd_Click()
If rs.RecordCount > 0 Then
rs.MoveNext
If (Not rs.EOF) Then

Prevcmd.Enabled = True
fill_data
Else
nextcmd.Enabled = False
Prevcmd.Enabled = True
fill_data
End If
End If

End Sub


here is where i get the error:

Code:

Private Sub fill_data()

If rs.BOF Or rs.EOF Then
txtFileNo = ""
txtYear = ""
txtRefNo = ""
txtSubject = ""
txtDate = ""

txtTo = ""
txtSendTo = ""

txtDir = ""
txtComments = ""
txtCheck = ""
txtJeha = ""
txtSender = ""
txtStaffName = ""
Else

If IsNull(rs!FileNo) Then txtFileNo = "" Else txtFileNo = rs!FileNo
If IsNull(rs!Year) Then txtYear = "" Else txtYear = rs!Year


If IsNull(rs!Subject) Then txtSubject = "" Else txtSubject = rs!Subject
If IsNull(rs!Date) Then txtDate = "" Else txtDate = rs!Date


If IsNull(rs!To) Then txtTo = "" Else txtTo = rs!To
If IsNull(rs!SendTo) Then txtSendTo = "" Else txtSendTo = rs!SendTo


If IsNull(rs!Directorate) Then txtDir = "" Else txtDir = rs!Directorate
If IsNull(rs!Comments) Then txtComments = "" Else txtComments = rs!Comments

If IsNull(rs!Jeha) Then txtJeha = "" Else txtJeha = rs!Jeha
If IsNull(rs!Sender) Then txtSender = "" Else txtSender = rs!Sender

If IsNull(rs!Check) Then txtCheck = "" Else txtCheck = rs!Check

If IsNull(rs!ñõñRefNo) Then txtRefNo = "" Else txtRefNo = rs!RefNo
If IsNull(rs!ñõñStaffName) Then txtStaffName = "" Else txtStaffName = rs!StaffName
'MsgBox (Val(rs!Jeha))

End If





txtFileNo.Locked = True
txtYear.Locked = True



End Sub


thankx

Item Not Found In Collection Or Named Ordinal
I think is an easy one for experts out there.
I'm tring to ad one assignment inside of Do While Not rsJobTranLabor.EOF Loop... Which tells me sme records are in th erecordset since it goes in th loop and also I see the others fields of the records go into the flexgrid when this one statement is not there.
I am trying to assign rsJobTranLabor!JobTran into a flex grid and I'm getting errors as if it's not finding the field. The select statment is below and the two statements I have tried are also below. I guess my symtax is wrong but I don't know wat to change it to.
Thanks for the help!


grdTime.TextMatrix(GridRow, 11) = rsJobTranLabor!JCTRAN_JobTranLabor!JobTran

grdTime.TextMatrix(GridRow, 11) = rsJobTranLabor!JobTran

strSQL = "Select TranYMD, WorkOrderNbr, DLHours, DLRate, ExtCost, JCTRAN_JobTranLabor.JobTran "
strSQL = strSQL & "As JCTran, DLRateType From JCTRAN_JobTranLabor "
strSQL = strSQL & "Inner Join JCTRAN_JobTranHdrs On JCTRAN_JobTranLabor.JobTran = JCTRAN_JobTranHdrs.JobTran "
strSQL = strSQL & "Where EmployeeID = '" & EmpID10 & "' "
strSQL = strSQL & "And TranYMD >= '" & gWeek(0).DateYMD & "' "
strSQL = strSQL & "And TranYMD <= '" & gWeek(6).DateYMD & "' "
strSQL = strSQL & "Order By TranYMD"
intTmp1 = DS0_OpenForwardOnly(dbJCTran, strSQL, rsJobTranLabor)

Help!!! Run-Time Error '3265' Item Cannot Be Found In The Corresponding To The...
Run-Time error '3265' Item cannot be found in the corresponding to the requested...

I use Microsoft Access group few column to form another view of table like below...


Code:
TRANSFORM Sum(Account.Money) AS SumOfMoney SELECT Account.Director FROM Account WHERE Account.Director IN (" & Item & ")GROUP BY Account.Director PIVOT Account.Director2"


then I use listview to show the result


Code:
StrCache = TRANSFORM Sum(Account.Money) AS SumOfMoney SELECT Account.Director FROM Account WHERE Account.Director IN (" & Item & ")GROUP BY Account.Director PIVOT Account.Director2"

RsCache.Open StrCache, aConn

If RsCache.RecordCount <> 0 Then
'RsCache.MoveFirst
While Not RsCache.EOF
Set itm = ListView1.ListItems.Add(, , RsCache.Fields(0).Value & "") itm.SubItems(1) = IIf(RsCache.Fields(1) = Null, " ", FormatCurrency(RsCache.Fields(1).Value))
itm.SubItems(2) = IIf(RsCache.Fields(2) = Null, " ", FormatCurrency(RsCache.Fields(2).Value))
itm.SubItems(3) = IIf(RsCache.Fields(3) = Null, " ", FormatCurrency(RsCache.Fields(3).Value))
itm.SubItems(4) = IIf(RsCache.Fields(4) = Null, " ", FormatCurrency(RsCache.Fields(4).Value))
RsCache.MoveNext
Wend
End If


but when built it prompt RunTime error..... How to solve if the item no found and jz left the field null?? and continue populate other value to listview?

LIST VIEW = ITEM NOT FOUND ERROR??
hey guys

i got a problem. run time error(3265) and item message is
item not found in this collection.

what i am try to is i want to move the selected data in listview(lv) into textbox by doubleclick the data list in lv. i can run it succesfully. the code as bellow:-
____________________________________________________________
Private Sub txtCDECustomer_Change()
Dim RST As Recordset
Dim pItem As ListItem
Dim SQL

SQL = "SELECT T_CustomerInfo.CusID, T_CustomerInfo.CusName FROM T_CustomerInfo " _
& "WHERE (((T_CustomerInfo.CusName) Like '" & txtCDECustomer & "*'));"

Set RST = DBS.OpenRecordset(SQL)
lvCDECustomer.ListItems.Clear

With RST

Do While Not .EOF

Set pItem = lvCDECustomer.ListItems.Add(, , !CusID)
pItem.SubItems(1) = !CusName

.MoveNext

Loop

End With

End Sub
____________________________________________________________

BUTTTTTT.....

i got another textbox and lv. the code is the same but for this objects there are run time error as i said at above. the code for second lv and textbox as bellow:-
____________________________________________________________

Private Sub txtCDESendTo_change()
Dim RSTSendTo As Recordset
Dim pItemSendTo As ListItem
Dim SQLSendTo

SQLSendTo = "SELECT T_SetupSendTo.SendToID, T_SetupSendTo.SendToID FROM T_SetupSendTo " _
& "WHERE (((T_SetupSendTo.SendTo) Like '" & txtCDESendTo & "*'));"

Set RSTSendTo = DBS.OpenRecordset(SQLSendTo)
lvCDESendTo.ListItems.Clear

With RSTSendTo
Do While Not .EOF
Set pItemSendTo = lvCDESendTo.ListItems.Add(, , !SendToID)
pItemSendTo.SubItems(1) = !SendTo <= error here

.MoveNext

Loop
End With

End Sub
____________________________________________________________

please help me plz

Item Not Found In The Collection Corresponding To Requested Name Or Ordinal
Hello code knights
I'm getting the above error with this database app. There is only a listbox and a textbox. I'm using Access 2k and MS Active X data obj 2.7.
Code:
Option Explicit
Private strMvFilePathName As String
Private basicConn As ADODB.Connection
Private rsMvRecordset As ADODB.Recordset
Dim mboolShow As Boolean
Dim mboolAdding As Boolean
'
Private Sub Form_Load()
' Set the location for the mdb
    strMvFilePathName = App.Path & "asic.mdb"
    
' Create a connection to the database
    Set basicConn = New ADODB.Connection
    basicConn.Open ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strMvFilePathName & ";Persist Security Info=False")

' to display from record set
    Set rsMvRecordset = New ADODB.Recordset
    With rsMvRecordset
' Attach recordset to connection
        .ActiveConnection = basicConn
' Make sure the data will be Updatable
        .CursorType = adOpenDynamic
        .CursorLocation = adUseClient
' Open recordset using SQL SELECT statement to select records
        .Open ("SELECT ID, Name FROM tblbasic")
    End With
    
    Call FormShow
    
End Sub

Private Sub FormShow()
   mboolShow = True
   With rsMvRecordset
      txtAge = Field2Str(!Age) ' error here
   End With
   mboolShow = False
End Sub

Public Function Field2Str(vntField As Variant) As String
   If IsNull(vntField) Then
      Field2Str = ""
   Else
      Field2Str = Trim$(CStr(vntField))
   End If
End Function

Public Function Field2Long(vntField As Variant) As Long
   If IsNull(vntField) Then
      Field2Long = -1
   Else
      Field2Long = CLng(vntField)
   End If
End Function

Private Sub ListLoad()
   Dim oRS As Recordset
   Dim strSQL As String
   
   strSQL = "SELECT ID, Name FROM tblbasic"
   
   Set oRS = New Recordset
   oRS.Open strSQL, basicConn, adOpenForwardOnly, adLockReadOnly
            
   lstNames.Clear
   Do Until oRS.EOF
      With lstNames
         .AddItem Trim$(oRS("Name"))
         .ItemData(.NewIndex) = oRS("ID")
      End With
      
      oRS.MoveNext
   Loop
   oRS.Close
   
   If lstNames.ListCount Then
      lstNames.ListIndex = 0
   End If
End Sub

..the Field2String and Field2long are in case an empty field is encountered. My Access has just two fields ID and Age. More to be added as the current crisis ceases.

Hal

"He knows so little it's hard to keep up with what he doesn't know". -- Hawkeye Pierce on Frank Burns

Item Cannot Be Found In The Collection Corresponding To The Requested Name Or Ordinal
Hello
This was working fine then this error pops up when I try to add a record "Item cannot be found in the collection corresponding to the requested name or ordinal"
During the save routine this pops up. Even earlier versions of this app that were working, are now doing this, just bizarre. I'm using VB 6 as a front end to Access '03. The main control is mschart.
Here is my save routine...
Code:
Private Sub cmdSave_Click()
  Dim mySQL As String
  On Error GoTo UpdateErr
    With rs
      .AddNew
      '!Weeks = Format(DTPicker1.Year) & "/" & DTPicker1.Month & "/" & DTPicker1.Day ' or here
      !Weeks = DTPicker1.Value ‘ error here
      !Analyzer = Analyzer
      !Humphrey = Humphrey
      !Accumulator = Accumulator
      !Pump = Pump
      !Regulator = Regulator
      !Card = Card
      !NDF = NDF
      !Solenoid = Solenoid
      .MovePrevious
    End With
  'insert into table
  mySQL = "INSERT INTO tbliface([Weeks], Analyzer, Humphrey, Accumulator, Pump, Regulator, Card, NDF,Solenoid) VALUES('" & DTPicker1.DataField & "');"
    Debug.Print mySQL
  cboStartLoad ' load combobox for start date range to display on chart
  cboEndLoad ' load combobox for end date range to display on chart
  Exit Sub
  'mbDataChanged = False
  FrameAdd.Visible = False
UpdateErr:
  MsgBox Err.Description
End Sub

I've tried every variation of the error line month, day year etc.
Any help is appreciated.

IM CONFUSED...ERROR 3265: ITEM CANNOT BE FOUND IN THE COLLECTION
Hello everyone...

i have this problem which bugging me yesterday for the whole day.

here it is...i have a database with a field name "contractor_id", but when i try to load the details or
even save a data into that field it displays an error message "3265: Item cannot be found in the collection
corresponding to the requested name or ordinal."

wherein, i have checked the existing table where that field resides and its there, so far only that field is
having a problem but the other fields along with it are working fine, i even checked by code if i have only
mispelled the field name but its correct.

need you help very badly...thanks a lot.



vhin

How To Search For An Item In A A Listview?
Hi,
I wanted to know how to search for an item in a listview?

Suppose, i've typed a word in a txtbox and i want to search for that in a listview, how to do it?

Also, how to make the current index of the listview point to that item i am searching for in case found?


Thanks in advance

ListView Search Item
Hey

I want to search an Item in a listview and delete it.

For example, I have the name John. I want to see if it's in the listview, if it's in the listview it must be deleted.

Thanks

How To Find The Next Search Item?
Right now I am using the Instr function to find certain texts I want to grab out of a HTML source code. Let's say for example I want to find the word "box" and the word box appears 9 times in the HTML source code. I can find the first "box" using Instr to find the beginning of "box" and another Instr to find the end. To extract the word I use the Mid function. How do I tell VB5 to go find the next "box" and extract that and then tell VB5 to stop when it cannot find anymore "box".

Example HTML code:
<b><font color="#000000">box</font></b>

This is my code:
Code:
Private Sub Form_Load()
'Declaring variables
    Dim str_url
    Dim search, search1
    Dim result, result1
    Dim length
    Dim word

'Declaring the search location
    str_url = Inet1.OpenURL("http://www.somewebsite.com")

'Declaring the searched character
    search = "box"
    search1 = "<" 'To indicate the end of the word

'Performing the search
    result = InStr(1, str_url, search)
    result1 = InStr(result, str_url, search1)
    length = result1 - result
    word = Mid(str_url, result, length)

'Displaying the find
    text1.text = word


    Any help would be greatly appreciated.

Using An Inputbox To Search DB For An Item
I am using ADODB to connect and manipulate a DB. What I am trying to do is write code so that a user can enter a number into an inputbox. Then I want to search my DB (the ID field) and try to find the number returned from the input box
If it does exist I want to populate some labels with the appropriate info from the item with that index.
If it does not exist I want a MSgbox to say item does not exist in DB. What I have so far is below.I am stuck because I dont know how to search the DB.

Private Sub cmdFind()

    strMsg = "Enter an item number to look up and press enter." _
    & Chr(13) & Chr(13) & "To cancel this operation press escape."
    strTitle = "Item Number Look up"
    strNumber = InputBox(strMsg, strTitle)
    
    If IsNumeric(strNumber) Then
        intID = Val(strNumber)
    Else
        answer = MsgBox("Enter Numeric Value only", vbOKOnly, "Sorry Invalid entry")
        Exit Sub
    End If

End sub

I have most of tis project complete but I am having a little grief on this part.

If any one has some suggestions it would be appreciated





Edited by - randyturpin on 1/14/2004 9:27:53 AM

Finding A String In A Column And Selecting The Contents In The Cell Beside The Found Item
Hi, I'm trying to put code in a form a form where if the user enters a string ie: 1989/12345 in textbox1 the code would look for the same string in a column 1 and select the text in the corresponding column 2 and input it into textbox2. (this should be done as soon as the data in textbox 1 is entered) I'm not sure if it is possible but if so any assistance would be greatfully appreciated.

Search All Instances Of Each Item In A List
Here's my situation: I have a long list of data. I want to search column "d" for a variable (entered somewhere) and each time that variable appears, I want the whole line to be copied to a new list. I can do the find command but I can't get it to loop through the whole list. Please help.

Last Item In A Listbox
A listbox normaly shows items 1 down to the maximum showable in that box despite of the value of .ListCount . How can I tell VB - after aplying the .AddItem-method - allway to show the .ListCount-item at the last line of the listbox (will say: display items [.ListCount-max. lines] to .ListCount)?

Thanks in advance!

Lightgun

For Each Item In Listbox...
Here is what im Trying to do:

Something like....

For Each Item in Listbox

MsgBox The Data of the item

Next

Its so simple, yet i havnt been able to figure it out =/

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