C
CJ
Good Day Groupies!
I have 2 combos, Category Name and Sub Category Name
Category gets it's data from the Category table, no problem. It has an
AfterUpdate requery for SubCategory.
SubCategory has the following SQL:
SELECT DISTINCT tblSubCategory.strSubCategory, tblInventory.[Category Name]
FROM tblSubCategory LEFT JOIN tblInventory ON tblSubCategory.strSubCategory
= tblInventory.[Sub Category Name]
WHERE (((tblInventory.[Category Name])=[Forms]![frmInventory]![Category
Name]))
ORDER BY tblSubCategory.strSubCategory;
Things are working fine except when I want to add a new SubCategory to an
existing Category.
I have the "standard" not in list code:
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strMsg As String
strMsg = strMsg & "Add " & NewData & " to the list?"
If MsgBox(strMsg, vbQuestion + vbYesNo, "Item Not Available") = vbNo
Then
Response = acDataErrContinue
Else
Set db = CurrentDb
Set rs = db.OpenRecordset("tblSubCategory", dbOpenDynaset)
On Error Resume Next
rs.AddNew
rs!strSubCategory = NewData
rs.Update
If Err Then
MsgBox "An error occurred. Please try again."
Response = acDataErrContinue
Else
Response = acDataErrAdded
End If
End If
It seems to work fine if I add a new Category and new SubCategory.
However, if I have an existing Category and add a new Sub, I can not move
to the next record or I get an "item not in list" error, depending on how
I have the Limit To List set.
Any ideas?
I have 2 combos, Category Name and Sub Category Name
Category gets it's data from the Category table, no problem. It has an
AfterUpdate requery for SubCategory.
SubCategory has the following SQL:
SELECT DISTINCT tblSubCategory.strSubCategory, tblInventory.[Category Name]
FROM tblSubCategory LEFT JOIN tblInventory ON tblSubCategory.strSubCategory
= tblInventory.[Sub Category Name]
WHERE (((tblInventory.[Category Name])=[Forms]![frmInventory]![Category
Name]))
ORDER BY tblSubCategory.strSubCategory;
Things are working fine except when I want to add a new SubCategory to an
existing Category.
I have the "standard" not in list code:
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strMsg As String
strMsg = strMsg & "Add " & NewData & " to the list?"
If MsgBox(strMsg, vbQuestion + vbYesNo, "Item Not Available") = vbNo
Then
Response = acDataErrContinue
Else
Set db = CurrentDb
Set rs = db.OpenRecordset("tblSubCategory", dbOpenDynaset)
On Error Resume Next
rs.AddNew
rs!strSubCategory = NewData
rs.Update
If Err Then
MsgBox "An error occurred. Please try again."
Response = acDataErrContinue
Else
Response = acDataErrAdded
End If
End If
It seems to work fine if I add a new Category and new SubCategory.
However, if I have an existing Category and add a new Sub, I can not move
to the next record or I get an "item not in list" error, depending on how
I have the Limit To List set.
Any ideas?