CharlieT302
Instructor
Hello Everyone,
I used the following code below to avoid having to write out a complete Dlookup formula when I need to reference it. However, the SD code, which produces a date within a series of records, will not display anything at all. As a test, I used the complete formula in conjunction with a Msgbox and it worked fine. Using the abbreviated SD, however, fails. Below is sample code that is having the error. I am assuming the issue is with Dim. I have tried different variations (Dim SDC, Dim SDC As Date, etc.)
Ideas?
Dim SDC
SD = DLookup("Serve_Date", "tbl_Meal_Orders_Site", "menu_ID = " & Me.Order_Menu_ID & " And Offer_vs_Serve = -1 " & " And Not IsNull([Serve_Date])")
'this code fails
If Me.Meal_Qty > 0 And (IsNull(Me.Serve_Date) Or Me.Serve_Date = "") Then
'Me.Serve_Date = SD
'this code works
If Me.Meal_Qty > 0 And (IsNull(Me.Serve_Date) Or Me.Serve_Date = "") Then
Me.Serve_Date = DLookup("Serve_Date", "tbl_Meal_Orders_Site", "menu_ID = " & Me.Order_Menu_ID & " And Offer_vs_Serve = -1 " & " And Not IsNull([Serve_Date])")
I used the following code below to avoid having to write out a complete Dlookup formula when I need to reference it. However, the SD code, which produces a date within a series of records, will not display anything at all. As a test, I used the complete formula in conjunction with a Msgbox and it worked fine. Using the abbreviated SD, however, fails. Below is sample code that is having the error. I am assuming the issue is with Dim. I have tried different variations (Dim SDC, Dim SDC As Date, etc.)
Ideas?
Dim SDC
SD = DLookup("Serve_Date", "tbl_Meal_Orders_Site", "menu_ID = " & Me.Order_Menu_ID & " And Offer_vs_Serve = -1 " & " And Not IsNull([Serve_Date])")
'this code fails
If Me.Meal_Qty > 0 And (IsNull(Me.Serve_Date) Or Me.Serve_Date = "") Then
'Me.Serve_Date = SD
'this code works
If Me.Meal_Qty > 0 And (IsNull(Me.Serve_Date) Or Me.Serve_Date = "") Then
Me.Serve_Date = DLookup("Serve_Date", "tbl_Meal_Orders_Site", "menu_ID = " & Me.Order_Menu_ID & " And Offer_vs_Serve = -1 " & " And Not IsNull([Serve_Date])")