Issues with date carried forward

lyatri

Registered User.
Local time
Today, 06:08
Joined
Dec 6, 2012
Messages
14
Hi all
I have a data entry form with a date on. I want the date once entered to carry forward until changed. I am using this VB code currently:
Private Sub Date_AfterUpdate()
If Not IsNull(Me.Date.Value) Then
Me.Date.DefaultValue = "#" & Me.Date.Value & "#"
End If
End Sub
This works however the date is reversed in the next record as in 22/01/13 becomes 13/01/22. I have changed the input mask on both the form and the table to no avail I have also tried creating an entirely fresh text box and still have an issue so maybe the prob is with the table or the code.

Any suggestions
Thanks
 
1. NEVER use the name of a function or property as a column name. Date, Year, Value, Name, etc are all poor choices for names. If you don't want to memorize the list of reserved words for VBA and SQL (who does), the best solution is to use descriptive phrases along with the simple nouns. OpenDate, SaleYear, PurchaseValue, CustomerName, etc.
2. This is a cross that all whose countries don't use the "standard ;)" mm/dd/yyyy format have to bear. If you define the columns as Date/Time and do not convert them to strings, you won't have any problems. Once you convert a date to a string and enclose it with #'s, you MUST use the US field order.
3. If you use input masks, you won't get the built in popup calendar. Personally, I never use input masks for dates. I find them to be more annoying than helpful. Just make sure that controls have a format defined and Access will not swap field order on you.

I can't find the link but if you search here you should find it. Someone has written an excellent article regarding this.
 

Users who are viewing this thread

Back
Top Bottom