Before I state my problem I want to say thanks to anyone who reads this post. I appreciate your time.
I have a simple form in an Access 2007 database. The form contains two combo boxes. Combo box 1 contains the names of all the base and linked tables in the database.
When the user selects a table name in combo box 1, I want combo box 2 show the list of fields for that table.
The code I have to populate combo box 2 with field names looks like this:
Problem is I get an run-time error 3420 ("Object invalid or no longer set"). When I Debug, the offending line is:
Can anyone point out what I'm doing wrong? I've looked at the code for too long and I can't see what's wrong with it.
Thanks,
sphinney
I have a simple form in an Access 2007 database. The form contains two combo boxes. Combo box 1 contains the names of all the base and linked tables in the database.
When the user selects a table name in combo box 1, I want combo box 2 show the list of fields for that table.
The code I have to populate combo box 2 with field names looks like this:
Code:
Private Sub Combo_Box_1_Change()
Dim FLD As String
Dim INDEXtdef As DAO.TableDef
Dim VarItm As Variant
'Initiate the FLD string variable
FLD = ""
Set INDEXtdef = CurrentDb.TableDefs(Combo_Box_1.Value)
For Each VarItm In INDEXtdef.Fields
'Build the string variable
FLD = FLD & VarItm.Name & "; "
Next
'Trim off the extra semi-colon and space
FLD = Left(FLD, Len(FLD) - 2)
Combo_Box_2.RowSource = FLD
End Sub
Code:
For Each VarItm In INDEXtdef.Fields
Thanks,
sphinney
Comment