473,385 Members | 1,492 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Problem with DateAdd and Default Value

missinglinq
3,532 Expert 2GB
Here's a poser! Using Access 2003 SP2

The Control Source for txtMealDate is defined at table level as Date/Time.

When this code is run
Expand|Select|Wrap|Line Numbers
  1. Private Sub txtMealDate_AfterUpdate()
  2.  txtMealDate.DefaultValue = DateAdd("d", 1, Me.txtMealDate)
  3.  MsgBox txtMealDate.DefaultValue
  4. End Sub
the messagebox pops up with the correct DefaultValue. But when I move to a new record, the date entered as default is 12/30/1899. I've deleted the form and re-created it , as well as the table. I've been taking cold medicines that have me kind of spacey, so I figure it's got to be something simple I'm overlooking. I'd appreciate any ideas, as my hair is already sparse and I'm pulling out more by the minute!

Linq ;0)>
Oct 24 '08 #1
8 3208
FishVal
2,653 Expert 2GB
Hello, Linq.

TextBox.DefaultValue property is of String type and date delimiters (#) should be added to a string value assigned to it.

Regards,
Fish.

P.S. Where did you get such a powerful medcine? ;)
Oct 24 '08 #2
missinglinq
3,532 Expert 2GB
Over the county!

Tried that! Tried wrapping it in CDate() as well.

Linq ;0)>
Oct 24 '08 #3
FishVal
2,653 Expert 2GB
Over the county!

Tried that! Tried wrapping it in CDate() as well.

Linq ;0)>
:)

I guess that means doesn't work.
But it does.

TextBox.DefaultValue is String type property.
(BTW, though I didn't check it personally, but it most like that date should be formatted like when displayed in that particular Textbox control)
Being such it gets and returns String type values.
Date delimiters, "#", has to be included in the string value assigned to the property.

txb.DefaultValue = "#" & dteVariable & "#"

P.S. What is an API (Active Pharmaceutical Ingridient LOL) of the medcine you've taken? :D
Oct 24 '08 #4
missinglinq
3,532 Expert 2GB
As I said, I tried wrapping it in the # delimiter, like you would if you were doing a hack tp simply carry a value forward, but couldn't get it to work. Like a dummy (or maybe a 'doped') I neglected to wrap the pound mark in quotes! This does it:

Expand|Select|Wrap|Line Numbers
  1. Private Sub txtMealDate_BeforeUpdate(Cancel As Integer)
  2.  txtMealDate.DefaultValue = "#" & DateAdd("d", 1, Me.txtMealDate) & "#"
  3. End Sub
Thanks for your help, Fish!

Linq ;0)>

BTW, the magic elixir is CODEINE!
Oct 24 '08 #5
FishVal
2,653 Expert 2GB
Thanks for your help, Fish!

Linq ;0)>
You are most welcome. :)

BTW, the magic elixir is CODEINE!
I would prefer Jagermeister - a magic of the Light Side. :D
Oct 24 '08 #6
missinglinq
3,532 Expert 2GB
Egads! Took Jagermeister on a camping trip once, my camping mates said I was actually howling at the moon before the the night was thru!

Linq ;0)>
Oct 24 '08 #7
NeoPa
32,556 Expert Mod 16PB
Hi guys.

Late to the party it seems, but I'm glad to see that Fish has helped you to resolve the issue Linq :)

12/30/1899 (or 30/12/1899 for Euros) is actually the date representation of 0 (not -1 as I'd anticipated. Why it starts before the beginning of the new century is a mystery to me).

I'm surprised a simple CDate() return value wouldn't work mind you.
Oct 25 '08 #8
missinglinq
3,532 Expert 2GB
I was too, Ade, but as John Walton used to say "Life's a mystery!"

;0)>
Oct 25 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: lofty | last post by:
Dear Lord, I'm trying to code a drop down for a date entry that gives the user the option of the current date plus the dates of the last 7 days. <% for i = -7 to -1 Response.write...
2
by: Jon | last post by:
Hi, I am trying to pick up records from a date range without much luck. For my example below I am trying to pick up all records made in the last month. However none are being found (my code is...
19
by: Lauren Quantrell | last post by:
I have a stored procedure using Convert where the exact same Convert string works in the SELECT portion of the procedure but fails in the WHERE portion. The entire SP is listed below....
1
by: Raghu | last post by:
Hello... I am running into a problem while running a query..can some1 help.. this is the query : ************** SELECT * from Table S where S.dtDate1 BETWEEN...
6
by: Mark Reed | last post by:
Hi Guru's, I have created a database to monitor hours I have worked as our payroll department are so crap. I work nights most of the time but occasionally I have to work on days. Between the hours...
3
by: Annette Massie | last post by:
I am trying to insert a record into a table via code and one of the values to add I would like as a dateadd calculation on a value from a query. My code looks like this: Set db = CurrentDb() ...
4
by: Drum2001 | last post by:
I have a report that acts as a time sheet for employees. It lists there "punch-in" and "punch-out and catagorizes them by week, with different totals.. At the end of each week is a total of all...
3
by: noone | last post by:
Hi, I am designing an application which displays news topics until midnight on the DisplayUntil date and then they should drop out. Unfortunately, they seem to be dropping out at mid-day. I'm...
2
by: ncsthbell | last post by:
I am having problems getting the end date to calculate correctly. I start with Quarter '03/02', (YY/QTR), for this it means it is for the 2nd qtr of 2003. My goal is to get the begin & end dates...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.