By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,231 Members | 1,707 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,231 IT Pros & Developers. It's quick & easy.

Problem with Date field

P: n/a
I have a problem with the following line of code.

rstOutput![ModifiedDate] = FormatDateTime("January 1, 2004", vbLongDate)

When I run this on my computer at home it runs without problem but when I
run it at work I get a Run-time error '3421' Data type conversion error.
I'm really stumped as to why this is. Both computers are Windows 2000 SP4
with Access 2000. The field [ModifiedDate] is a Date/Time field with a
format of Long Date set. Does anyone have an idea what is going on here?

Thanks
Dustin

Nov 12 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
> I have a problem with the following line of code.

rstOutput![ModifiedDate] = FormatDateTime("January 1, 2004", vbLongDate)

When I run this on my computer at home it runs without problem but when I
run it at work I get a Run-time error '3421' Data type conversion error.
I'm really stumped as to why this is. Both computers are Windows 2000 SP4
with Access 2000. The field [ModifiedDate] is a Date/Time field with a
format of Long Date set. Does anyone have an idea what is going on here?


Don't convert your date string to a formatted string, just convert the date
string to a date:

rstOutput![ModifiedDate] = CDate("January 1, 2004")

The actual display of your date value is controlled by the "Format" property of
the field or control, but the actual date value is a number.

--
Bruce M. Thompson, Microsoft Access MVP
bt******@mvps.org (See the Access FAQ at http://www.mvps.org/access)
NO Email Please. Keep all communications

within the newsgroups so that all might benefit.<<
Nov 12 '05 #2

P: n/a
I have struggled a lot with similar problems. You will find in the windows
control panel, in Regional settings, settings for long and short date
format. They might be different from one computer to another, and controls
date formats in all your windows programs, and they affect your code.
Putting your database on a server with several users, gets you really into
trouble.
And the trick is: Store only the date value, and use format property to
decide how to display it.

Brgds
Rolf
"Bruce M. Thompson" <bthmpson@big_NOSPAM_foot.com> wrote in message
news:10*************@corp.supernews.com...
I have a problem with the following line of code.

rstOutput![ModifiedDate] = FormatDateTime("January 1, 2004", vbLongDate)

When I run this on my computer at home it runs without problem but when I
run it at work I get a Run-time error '3421' Data type conversion error. I'm really stumped as to why this is. Both computers are Windows 2000 SP4 with Access 2000. The field [ModifiedDate] is a Date/Time field with a
format of Long Date set. Does anyone have an idea what is going on
here?
Don't convert your date string to a formatted string, just convert the date string to a date:

rstOutput![ModifiedDate] = CDate("January 1, 2004")

The actual display of your date value is controlled by the "Format" property of the field or control, but the actual date value is a number.

--
Bruce M. Thompson, Microsoft Access MVP
bt******@mvps.org (See the Access FAQ at http://www.mvps.org/access) NO Email Please. Keep all communications

within the newsgroups so that all might benefit.<<

Nov 12 '05 #3

P: n/a
This is the case between the two machines.. But since others do you it I
have one question that may sound dumb but...

How do you store only the date value?

Thanks
Dustin

"R.A.Balder" <R_********@xhotmail.com> wrote in message
news:Ha*********************@juliett.dax.net...
I have struggled a lot with similar problems. You will find in the windows control panel, in Regional settings, settings for long and short date
format. They might be different from one computer to another, and controls date formats in all your windows programs, and they affect your code.
Putting your database on a server with several users, gets you really into
trouble.
And the trick is: Store only the date value, and use format property to
decide how to display it.

Brgds
Rolf
"Bruce M. Thompson" <bthmpson@big_NOSPAM_foot.com> wrote in message
news:10*************@corp.supernews.com...
I have a problem with the following line of code.

rstOutput![ModifiedDate] = FormatDateTime("January 1, 2004", vbLongDate)
When I run this on my computer at home it runs without problem but when
I
run it at work I get a Run-time error '3421' Data type conversion error. I'm really stumped as to why this is. Both computers are Windows 2000 SP4 with Access 2000. The field [ModifiedDate] is a Date/Time field with

a format of Long Date set. Does anyone have an idea what is going on

here?

Don't convert your date string to a formatted string, just convert the

date
string to a date:

rstOutput![ModifiedDate] = CDate("January 1, 2004")

The actual display of your date value is controlled by the "Format"

property of
the field or control, but the actual date value is a number.

--
Bruce M. Thompson, Microsoft Access MVP
bt******@mvps.org (See the Access FAQ at http://www.mvps.org/access)
> NO Email Please. Keep all communications

within the newsgroups so that all might benefit.<<


Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.