Solved

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

Posted on 2009-07-10
1
148 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

770 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