Hello,
I am trying to cascade two combo boxes on the same form. The first box (cboType) is derived from a table, the rowsource being:
SELECT tblTypes.Type_ID, tblTypes.Type
FROM tblTypes;
The second box (cboSubtype) is derived from a table, the rowsource being:
SELECT tblSubtypes.SubType_ID, tblSubtypes.SubType_Name, tblSubtypes.Type_ID
FROM tblSubtypes;
In the AfterUpdate procedure of the first box, I have put the following code:
Private Sub cboType_AfterUpdate()
Me!cboSubtype = Null
If IsNull(cboType) Then
Me!cboType.SetFocus
Me!cboSubtype.Enabled = False
Else
Me!cboSubtype.SetFocus
Me!cboSubtype.RowSource = ReplaceWhereClause(Me!cboSubtype.RowSource, "Where Type_ID = " & _ Me!cboType)*****
Me!cboSubtype.Requery
End If
End Sub
I have checked the value of cboType in the immediate window and it returns a numeric value based on the selection in the combo box.
I am persistently getting an error 'Sub or Function not defined' with Me!cboType highlighted (indicated with *). I have tried to change the expression to a string with quotes, but then it says 'Expected end of statement'.
What am I doing wrong? Any help would be greatly appreciated.
Thanks a lot,
Rudra
I am trying to cascade two combo boxes on the same form. The first box (cboType) is derived from a table, the rowsource being:
SELECT tblTypes.Type_ID, tblTypes.Type
FROM tblTypes;
The second box (cboSubtype) is derived from a table, the rowsource being:
SELECT tblSubtypes.SubType_ID, tblSubtypes.SubType_Name, tblSubtypes.Type_ID
FROM tblSubtypes;
In the AfterUpdate procedure of the first box, I have put the following code:
Private Sub cboType_AfterUpdate()
Me!cboSubtype = Null
If IsNull(cboType) Then
Me!cboType.SetFocus
Me!cboSubtype.Enabled = False
Else
Me!cboSubtype.SetFocus
Me!cboSubtype.RowSource = ReplaceWhereClause(Me!cboSubtype.RowSource, "Where Type_ID = " & _ Me!cboType)*****
Me!cboSubtype.Requery
End If
End Sub
I have checked the value of cboType in the immediate window and it returns a numeric value based on the selection in the combo box.
I am persistently getting an error 'Sub or Function not defined' with Me!cboType highlighted (indicated with *). I have tried to change the expression to a string with quotes, but then it says 'Expected end of statement'.
What am I doing wrong? Any help would be greatly appreciated.
Thanks a lot,
Rudra