Design by Sue
Registered User.
- Local time
- Today, 15:40
- Joined
- Jul 16, 2010
- Messages
- 816
I am trying to write code to detect if there are related records in a table to the item selected on a form. I am trying to use DCount but must have an error in my code. Please Please help.
Here is my code:
If DCount("[Shade Type]", "[Item Master TBL]", "[Shade Type]" = "Me.Shade_Type") > 0 Then
MsgBox "You cannot delete this type because it is used in the database.", vbExplination, "Cannot Delete"
Exit Sub
End If
Shade Type is the column in Item Master TBL where I am trying to find the related records. My criteria (I am trying to make) is where Shade Type in the table matches the Shade Type on the open form. When there are more than none, I want the message box to appear.
Please if someone can help me I would be so grateful - this has taken a day to get this far and I still am nowhere.
Sue
Here is my code:
If DCount("[Shade Type]", "[Item Master TBL]", "[Shade Type]" = "Me.Shade_Type") > 0 Then
MsgBox "You cannot delete this type because it is used in the database.", vbExplination, "Cannot Delete"
Exit Sub
End If
Shade Type is the column in Item Master TBL where I am trying to find the related records. My criteria (I am trying to make) is where Shade Type in the table matches the Shade Type on the open form. When there are more than none, I want the message box to appear.
Please if someone can help me I would be so grateful - this has taken a day to get this far and I still am nowhere.
Sue