Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Errors when trying to navigate records on subform 1

Status
Not open for further replies.

jamez05

Programmer
Jul 29, 2005
130
US
I have a query that populates a form on load:
Code:
    'Populate Class List box
    Dim strSQL As String
    strSQL = "SELECT DISTINCT Class from tblChemClass ORDER BY Class"
    Form![UpdateChemClass]![UpdateChemClassSub]![lstClass].ColumnCount = 1
    Form![UpdateChemClass]![UpdateChemClassSub]![lstClass].ColumnHeads = False
    Form![UpdateChemClass]![UpdateChemClassSub]![lstClass].RowSourceType = "table/query"
    Form![UpdateChemClass]![UpdateChemClassSub]![lstClass].RowSource = strSQL

My subform can have multiple records so there is a navigation bar at the bottom. I'm using the oncurrent to try and highlight the listbox option values based on the record. The problem is that I can navigate through the first one or two records, then it blows up and errors. It has something to do with the select box. When I comment the part out about "Me.lstClass.Selected(i) = True" , it works. When I uncomment it, it blows up:
Code:
    For i = 0 To Me.lstClass.ListCount - 1 Step 1
        If Me.lstClass.ItemData(i) = Me.TxtClass.Value Then
            Me.lstClass.Selected(i) = True - comment this out and it works fine?
        End If
    Next i
 
I did not see anything wrong with your code, particularly on the second part.

Could you post the error message?

Seaport
 
Just give the general error that MS Access has an error and needs to close. Report this error?
 
My guess is that something is wrong with your vb modules in the database. Backup your database and then compact and repair it.

If the problem persists, decompile and re-compile it.

Decompile command for Access 2000:
"F:\Program Files\Microsoft Office\Office\MSACCESS.EXE" "c:\x.mdb" /decompile
Code for Access 2003
"C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE" "c:\x.mdb" /decompile

Seaport
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top