Solved

Assigning Caption value in VB6 app to value in Database, worked but now no longer

Posted on 2009-07-10
1
147 Views
Last Modified: 2013-12-26
Hi

I have just had to make amendments to one of our applications.  Since making amendments I now receive 3265 error as item does not exist in collection

My code is below.  All of this worked previously.  The only chnage I have made is incorporate a new recordset into application and a few more vb boxes

Here is code that was amended

Private Sub cmdFilterNomAdd_Click()
Dim strName(8) As String
Dim Index As Integer
Dim strTitles As Variant
Dim strGrpTitles As Variant
Dim strGroup(4) As String
Dim response As Integer

strTitles = Array("Name", "Rank", "Appointment", "Address Line 1", "Address Line 2", "Address Line 3", "Address Line 4", "Address Line 5", "Tel Number")
For Index = 0 To 8
    strName(Index) = InputBox(strTitles(Index), "New Nominee / Authority details")
    If Index = 0 And strName(0) = "" Then
        MsgBox "A name is required", vbCritical Or vbOKOnly
        Exit Sub
    End If
Next


' This was adding new people to different projects e.g. RAF, SALAM
For Index = 0 To 4
    response = MsgBox("Is the contact a member of " & frmIntegration.cboDMRL.List(Index), vbYesNo, "Assigning Contact Groups")
    If response = vbYes Then
        strGroup(Index) = frmIntegration.cboDMRL.List(Index)
    Else
        strGroup(Index) = ""
    End If
Next

With rstFilterNames
    .AddNew
    !Name = strName(0)
    !Rank = strName(1)
    !Appointment = strName(2)
    !Add1 = strName(3)
    !Add2 = strName(4)
    !Add3 = strName(5)
    !Add4 = strName(6)
    !Add5 = strName(7)
    !Tel = strName(8)
    .Update
End With
rstFilterNames.MoveLast

For Index = 0 To 4
    If strGroup(Index) <> "" Then
        With rstzGroups
            .AddNew
           !ID = rstFilterNames.Fields("ID")
            !DMRL = strGroup(Index)
            .Update
       End With
    End If
Next

With lstFilterNames
    .ListItems.Add , , strName(1)
    .ListItems.Item(.ListItems.Count).ListSubItems.Add , , strName(0)
    .ListItems.Item(.ListItems.Count).ListSubItems.Add , , strName(2)
    .ListItems.Item(.ListItems.Count).ListSubItems.Add , , strName(3)
    .ListItems.Item(.ListItems.Count).ListSubItems.Add , , strName(4)
    .ListItems.Item(.ListItems.Count).ListSubItems.Add , , strName(5)
    .ListItems.Item(.ListItems.Count).ListSubItems.Add , , strName(6)
    .ListItems.Item(.ListItems.Count).ListSubItems.Add , , strName(7)
    .ListItems.Item(.ListItems.Count).ListSubItems.Add , , strName(8)
End With
End Sub

I have also attached the code that connects all forms and procedures together.

It is bugging me.  This is probably so simple in the fact all I need is the lblUnitID.caption to represent the ID
from FilterNames recordset

Can anyon ehelp me out

Private Sub Command2_Click()

Dim Index As Byte

If cboDMRL.text = "" Then

    MsgBox "Please select Data Module type before continuing", vbOKOnly, "Data Module Type Not Selected"

    Exit Sub

End If

frmFilterNames.Show vbModal

If Not FilterBrowseCancel Then  'check if form cancelled
 

    txtUnitName.text = rstFilterNames("Name")

    txtUnitTitle.text = rstFilterNames("Rank")

    txtUnitAppointment.text = rstFilterNames("Appointment")

    For Index = 0 To 5

        txtUnitAdd(Index).text = rstFilterNames(Index + 2)

    Next

    lblunitID.Caption = rstFilterNames("ID") - This line is causing error and bug

End If
 

End Sub

Open in new window

VB6-App-code.txt
0
Comment
Question by:rustystefan
1 Comment
 

Accepted Solution

by:
rustystefan earned 0 total points
ID: 24824189
Please ignore question.

Dut o my oversight and long week I just realised what I had done and hadn't referenced lblunitID.Caption = rstFilterNames("ID") to correct field in database of zFilterNames.ID instead

Obviously this worked
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now