G
Guest
I am trying to sort out a sub category, but for some reason I am having
trouble with my answers. I have two tables one called tblcategory and another
called tblsubcategory. I would like tblsubcategory to only show whatever is
relevant to what has been chosen from tblcategory. At the moment when I
choose a sub category I get an Enter Parameter window, instead of the options
which I have available in tblsubcategory.
I have a relationship set up between the two tables - tblcategoryid.
The script below is what I have so far.
Option Compare Database
Private Sub Subcategory_BeforeUpdate(Cancel As Integer)
End Sub
Private Sub Category_AfterUpdate()
Dim sSubcategorySource As String
sSubcategorySource = "SELECT [tblsubcategory].[tblsubcategoryid],
[tblsubcategory].[tblcategoryid], [tblsubcategory].[subcategory] " & _
"FROM tblsubcategory " & _
"WHERE [tblcategoryid] = " & Me.Category.Value
Me.SubCategory.RowSource = sSubcategorySource
Me.SubCategory.Requery
End Sub
-----------------------
The Row Source for the Category is :
SELECT [category_Query].[Category] FROM category_Query;
The Row Source for the Sub Category is (with IT changing to whatever has
been chosen in the category:
SELECT [tblsubcategory].[tblsubcategoryid],
[tblsubcategory].[tblcategoryid], [tblsubcategory].[subcategory] FROM
tblsubcategory WHERE [tblcategoryid] = IT
trouble with my answers. I have two tables one called tblcategory and another
called tblsubcategory. I would like tblsubcategory to only show whatever is
relevant to what has been chosen from tblcategory. At the moment when I
choose a sub category I get an Enter Parameter window, instead of the options
which I have available in tblsubcategory.
I have a relationship set up between the two tables - tblcategoryid.
The script below is what I have so far.
Option Compare Database
Private Sub Subcategory_BeforeUpdate(Cancel As Integer)
End Sub
Private Sub Category_AfterUpdate()
Dim sSubcategorySource As String
sSubcategorySource = "SELECT [tblsubcategory].[tblsubcategoryid],
[tblsubcategory].[tblcategoryid], [tblsubcategory].[subcategory] " & _
"FROM tblsubcategory " & _
"WHERE [tblcategoryid] = " & Me.Category.Value
Me.SubCategory.RowSource = sSubcategorySource
Me.SubCategory.Requery
End Sub
-----------------------
The Row Source for the Category is :
SELECT [category_Query].[Category] FROM category_Query;
The Row Source for the Sub Category is (with IT changing to whatever has
been chosen in the category:
SELECT [tblsubcategory].[tblsubcategoryid],
[tblsubcategory].[tblcategoryid], [tblsubcategory].[subcategory] FROM
tblsubcategory WHERE [tblcategoryid] = IT