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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing contents of a box conflicting with BeforeUpdate event

Status
Not open for further replies.

iamdad25

Technical User
Jun 1, 2001
1
US
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??
 
Well, when exactly is it giving you the error and what is does it say? If its halting just because you've got a "-" there.. try putting If SUBCATEGORY = "-" Then Exit Sub right before you perform the recalc. I may be totally off on what its doing but thats all that I can pull out of your discription right now. (The fact that I'm writing this after being up for 18 hours doesn't help this X-)) Try explaining a little more about your problem if thats not it. -Dustin
Rom 8:28
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top