Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
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…
Suggested Courses

618 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