Solved

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

Posted on 2009-07-10
1
151 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…

726 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