?
Solved

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

Posted on 2009-07-10
1
Medium Priority
?
152 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month13 days, 11 hours left to enroll

800 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