The DoCmd.RunSQL method below keeps returning me the error "Criteria Type Mismatch". I believe that this error can be traced to the Dlookup fnction that I use inside my SQL code. I am new to writing VBA modules in Access (and to using VBA in general. Is there an obvious mistake someone can point out? Any tips for using this kind of code in VBA?
Your help is greatly appreciated!
Rgards,
Flo 79
'My Code
-----------------------------------------------------------
On Error GoTo Delete_Categories2_Err
Dim ID_New As Long
Dim ID_Old As Long
ID_New = Me.ID_New.Value
ID_Old = Me.ID_Old.Value
DoCmd.SetWarnings False
If (Eval("'" & ID_New & "' is not null")) Then
DoCmd.RunSQL "UPDATE Item_SubCategories INNER JOIN Transactions ON Item_SubCategories.SubCategoryID = Transactions.SubCategoryID SET Transactions.SubCategoryID = '" DLookup("[SubCategoryID]", "Item_SubCategories", "[CategoryID]='" & ID_New & "' AND [SubCategoryName]='<Unfiled>'") & "'" & _
"WHERE (((Transactions.SubCategoryID)= '" & DLookup("[SubCategoryID]", "Item_SubCategories", "[CategoryID]='" & ID_Old & "' AND [SubCategoryName]='<Unfiled>'") & "')));"
End If
Your help is greatly appreciated!
Rgards,
Flo 79
'My Code
-----------------------------------------------------------
On Error GoTo Delete_Categories2_Err
Dim ID_New As Long
Dim ID_Old As Long
ID_New = Me.ID_New.Value
ID_Old = Me.ID_Old.Value
DoCmd.SetWarnings False
If (Eval("'" & ID_New & "' is not null")) Then
DoCmd.RunSQL "UPDATE Item_SubCategories INNER JOIN Transactions ON Item_SubCategories.SubCategoryID = Transactions.SubCategoryID SET Transactions.SubCategoryID = '" DLookup("[SubCategoryID]", "Item_SubCategories", "[CategoryID]='" & ID_New & "' AND [SubCategoryName]='<Unfiled>'") & "'" & _
"WHERE (((Transactions.SubCategoryID)= '" & DLookup("[SubCategoryID]", "Item_SubCategories", "[CategoryID]='" & ID_Old & "' AND [SubCategoryName]='<Unfiled>'") & "')));"
End If