Gday all, having issues storing dates as variables. The intent of this beforeUpdate() function is to check the 'latest update' field of the Product table and if the latest update of the product was over 2 weeks prior then undoChange. The problem is that this is only working for some of the products in the table. I tested whats being assigned to the variable by outputting the result to a text box on the form. some are coming back with 12:00:00 am and some come back with the date format that i want, ie '20/12/2012. And even after I update these products that return the correct date values they still return the correct format so its not updating thats the problem. Though all new products that I insert into the table only return 12:00:00am. Im a beginner programmer so this has me fairly stumped. Anyway heres the code...
PS . I apologise for the poorly named command buttons and text boxes. Ill get round to changing the names at some point
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim CurrentDate As Date
Dim UndoneAction As Boolean
Dim SelectedProduct As String
Dim ProductName As String
Dim ProductDate As Date
Dim varDateDiff As Integer
Dim dbs As DAO.Database
Dim Product As DAO.Recordset
UndoneAction = False
SelectedProduct = Me.ProductName
CurrentDate = Date
Set dbs = CurrentDb
Set Product = dbs.OpenRecordset("Product")
Product.GetRows
If Product("ProductName").Value = SelectedProduct Then
ProductDate = Product("lastUpdate").Value
End If
' TEST
Me.Text21.Value = ProductDate
If DateDiff("d", CurrentDate, ProductDate) <= -14 Then
MsgBox ("The Product Price has not been updated for a while.. Please recheck this price with the Supplier then Update the product before continuing ")
DoCmd.RunCommand acCmdUndo
UndoneAction = True
End If
If UndoneAction = False And MsgBox("Save Changes to this Record", vbQuestion + vbYesNo) = vbNo Then
DoCmd.RunCommand acCmdUndo
End If
End Sub
PS . I apologise for the poorly named command buttons and text boxes. Ill get round to changing the names at some point

Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim CurrentDate As Date
Dim UndoneAction As Boolean
Dim SelectedProduct As String
Dim ProductName As String
Dim ProductDate As Date
Dim varDateDiff As Integer
Dim dbs As DAO.Database
Dim Product As DAO.Recordset
UndoneAction = False
SelectedProduct = Me.ProductName
CurrentDate = Date
Set dbs = CurrentDb
Set Product = dbs.OpenRecordset("Product")
Product.GetRows
If Product("ProductName").Value = SelectedProduct Then
ProductDate = Product("lastUpdate").Value
End If
' TEST
Me.Text21.Value = ProductDate
If DateDiff("d", CurrentDate, ProductDate) <= -14 Then
MsgBox ("The Product Price has not been updated for a while.. Please recheck this price with the Supplier then Update the product before continuing ")
DoCmd.RunCommand acCmdUndo
UndoneAction = True
End If
If UndoneAction = False And MsgBox("Save Changes to this Record", vbQuestion + vbYesNo) = vbNo Then
DoCmd.RunCommand acCmdUndo
End If
End Sub