In order to disply only the subcategories that pertain to a given category, I use the following:
Private Sub CATEGORY_AfterUpdate()
Me.Recalc
End Sub
The Row Source query is:
SELECT DISTINCT [Categories].[Subcategory], [Categories].[Category] FROM Categories WHERE (([Categories].[Category]=[Forms]![Issue Database]![Category]));
That works fine. However, I also want to use the BeforeUpdate event for the form to assure that the user selects a subcategory (does not leave it blank). Every attempt so far has failed. Most recently, I put "-" in as a subcategory in the Category table, and used it also as the default in the subcategory control. Then I used this:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If SUBCATEGORY = "-" Then
MsgBox "Subcategory cannot be empty."
Cancel = True
End If
End Sub
Unfortunately, I get runtime error 2169 as a result of the Me.Recalc statement.
Any ideas how to achieve my goal??
Private Sub CATEGORY_AfterUpdate()
Me.Recalc
End Sub
The Row Source query is:
SELECT DISTINCT [Categories].[Subcategory], [Categories].[Category] FROM Categories WHERE (([Categories].[Category]=[Forms]![Issue Database]![Category]));
That works fine. However, I also want to use the BeforeUpdate event for the form to assure that the user selects a subcategory (does not leave it blank). Every attempt so far has failed. Most recently, I put "-" in as a subcategory in the Category table, and used it also as the default in the subcategory control. Then I used this:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If SUBCATEGORY = "-" Then
MsgBox "Subcategory cannot be empty."
Cancel = True
End If
End Sub
Unfortunately, I get runtime error 2169 as a result of the Me.Recalc statement.
Any ideas how to achieve my goal??