Hello all,
I read part of a string (TSFilename) to convert to dates and display
in text box..
It looks fine, but vba doesn't believe they are dates.
Retype the same dates in the textboxes and vba accepts it..
can anyone advise..
Thanks.
TSFileName is "xx-xxx-2007-05-10to2007--5-20.xls"
Text boxes are formatted to date "dd/mm/yyy"
here's a snippet..
varStartDate = Mid(TSFileName, 8, 10)
varEndDate = Mid(TSFileName, 20, 10)
datStartDate = varStartDate
datEndDate = varEndDate
Me![DateStart] = Format(datStartDate, "dd/mm/yyyy")
Me![DateEnd] = Format(datEndDate, "dd/mm/yyyy") 2 1616
"oldeast" <ol*****@bigpond.net.auwrote in message
<11**********************@i38g2000prf.googlegroups .com>:
Hello all,
I read part of a string (TSFilename) to convert to dates and display
in text box..
It looks fine, but vba doesn't believe they are dates.
Retype the same dates in the textboxes and vba accepts it..
can anyone advise..
Thanks.
TSFileName is "xx-xxx-2007-05-10to2007--5-20.xls"
Text boxes are formatted to date "dd/mm/yyy"
here's a snippet..
varStartDate = Mid(TSFileName, 8, 10)
varEndDate = Mid(TSFileName, 20, 10)
datStartDate = varStartDate
datEndDate = varEndDate
Me![DateStart] = Format(datStartDate, "dd/mm/yyyy")
Me![DateEnd] = Format(datEndDate, "dd/mm/yyyy")
I think that one of the safest methods of retrieving a date out of a
string, is to use DateSerial
Me![DateStart] = DateSerial(Mid$(TSFileName, 8, 4), _
Mid$(TSFileName, 13, 2), Mid$(TSFileName, 16, 2))
Note that when you use the Format function on a date, what you're
doing, is taking a valid date, convert it to a string, and have
Access do an implicit cast back to date by assigning this string to
a control formatted as date. This might give unpredictable results.
--
Roy-Vidar
On May 29, 4:44 pm, RoyVidar <roy_vidarNOS...@yahoo.nowrote:
"oldeast" <olde...@bigpond.net.auwrote in message
<1180426808.788281.148...@i38g2000prf.googlegroups .com>:
Hello all,
I read part of a string (TSFilename) to convert to dates and display
in text box..
It looks fine, but vba doesn't believe they are dates.
Retype the same dates in the textboxes and vba accepts it..
can anyone advise..
Thanks.
TSFileName is "xx-xxx-2007-05-10to2007--5-20.xls"
Text boxes are formatted to date "dd/mm/yyy"
here's a snippet..
varStartDate = Mid(TSFileName, 8, 10)
varEndDate = Mid(TSFileName, 20, 10)
datStartDate = varStartDate
datEndDate = varEndDate
Me![DateStart] = Format(datStartDate, "dd/mm/yyyy")
Me![DateEnd] = Format(datEndDate, "dd/mm/yyyy")
I think that one of the safest methods of retrieving a date out of a
string, is to use DateSerial
Me![DateStart] = DateSerial(Mid$(TSFileName, 8, 4), _
Mid$(TSFileName, 13, 2), Mid$(TSFileName, 16, 2))
Note that when you use the Format function on a date, what you're
doing, is taking a valid date, convert it to a string, and have
Access do an implicit cast back to date by assigning this string to
a control formatted as date. This might give unpredictable results.
--
Roy-Vidar- Hide quoted text -
- Show quoted text -
Thanks for the reply.
I should have verified the text boxes with IsDate function as well. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Riley |
last post by:
The date fields being saved by a VB program were being saved
as #2003-11-22#. For reasons unknown to me these dates began
to be saved as "11/22/2003"
All of these dates were made dates with the...
|
by: Fons Dijkstra |
last post by:
Hello,
I'm using the mx.ODBC.Windows package in order to read/write a MSAccess
database. Everything works fine apart from the DATE format handling. I'm
using the default "datetimeformat" (i.e....
|
by: duikboot |
last post by:
Hi all,
I'm trying to export a view tables from a Oracle database to a Mysql
database. I create insert statements (they look alright), but it all goes
wrong when I try to execute them in Mysql,...
|
by: Thomas W |
last post by:
I'm developing a web-application where the user sometimes has to enter
dates in plain text, allthough a format may be provided to give clues.
On the server side this piece of text has to be parsed...
|
by: Frank |
last post by:
For my website i would like to display the age of my son in years,
months, days and hours.
For now i manage to get a result for totals. Like the total number of
days.
This is the beginning:
...
|
by: Lapchien |
last post by:
done homework on Usenet and still stuck...
I have a parameter query that asks the user to input the 'slip reference'
based on the accounting period. This has now changed slightly so that the...
|
by: Duppypog |
last post by:
I'm trying to compare a date stored in a database with today's date using an
If statement, but it's not returning true. Example, value in database is
11/5/2003 with today being 11/6/2003. Can...
|
by: @sh |
last post by:
For some reason guys my SQL string isn't working and I'm probably doing
something stupid?
SELECT *
FROM sol_session
SELECT *
FROM SOL_Session
WHERE DateGiven...
|
by: sherifffruitfly |
last post by:
Hi,
I'm using an adaptation of excel-reading code that's all over the
internet - I don't much like or understand it, but it has worked for me
in the past.... beggars can't be choosers... :
...
|
by: ccwells |
last post by:
Hi,
I am a novice to VB, using Access 2003 on a XP-SP2 platform, and I have a small database for tracking expenses, and want to be able to filter my expense report by date. I currently have a...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
| |