473,320 Members | 1,858 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,320 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 3200
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
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
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.