Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 11th, 2008, 06:11 AM
Authorized User
 
Join Date: Feb 2008
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to hewstone999
Default Formatting Problem

The code below imports the file Modified Time and Date into a table. However the value in the table = '39491.4423611111' , it should be: 13-Feb-2008 10:37:00. I've tried changing the data types to "Date/Time" and "Text" and still get the same value. How can i change it so it show the correct value?

The code below show this:

** Please Note **
'coltext = Table name - this value was from the Open Dialog box
'sbuffer2 = the file name


 SQL = "Create TABLE " & coltext & "_FileDateAndTime (FileDate Text)"
 DoCmd.RunSQL SQL
 SQL17 = "ALTER TABLE " & coltext & "_FileDateAndTime ADD COLUMN FileTime Text"
 DoCmd.RunSQL SQL17


    Dim FName As String
    Dim Result As Boolean
    Dim TheNewTime As Double
    Dim WhatTime As FileDateToProcess

    FName = "E:\CSC\LDMS\LDMSDatabaseApp\MPI IFF Lorenzo\" & sBuffer2
    WhatTime = FileDateLastModified

    TheNewTime = GetFileDateTime(FileName:=FName, WhichDateToGet:=WhatTime)
    If TheNewTime < 0 Then
       Debug.Print "An error occurred in GetFileDateTime"
    Else

    sSQL = "INSERT INTO " & coltext & "_FileDateAndTime (FileDate) VALUES ('" & TheNewTime & "')"
    DoCmd.RunSQL sSQL

    End If

 
Old March 11th, 2008, 06:23 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Try changing this: Dim TheNewTime As Double

To this: Dim TheNewTime As Date

Did that help?


mmcdonal

Look it up at: http://wrox.books24x7.com
 
Old March 11th, 2008, 07:04 AM
Authorized User
 
Join Date: Feb 2008
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to hewstone999
Default

Quote:
quote:Originally posted by mmcdonal
 Try changing this: Dim TheNewTime As Double

To this: Dim TheNewTime As Date

Did that help?


mmcdonal

Look it up at: http://wrox.books24x7.com

Yes it works :)

How could i get a time value from this aswell as the file also gets updated every 3 hours, thanks

 
Old March 11th, 2008, 07:17 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Ooops, sorry, you need a double for some reason. Try this:

Dim TheNewTime As Double
Dim WhatTime As FileDateToProcess
Dim dtDateTime As Date

...

TheNewTime = GetFileDateTime(FileName:=FName, WhichDateToGet:=WhatTime)

dtDateTime = TheNewTime

The Double is needed to preserve the decimal places, which the previous change was eliminating.

Then post dtDateTime to here:

sSQL = "INSERT INTO " & coltext & "_FileDateAndTime (FileDate) VALUES (#" & dtDateTime & "#)"

if this field is a date/time field.

Did that work?




mmcdonal

Look it up at: http://wrox.books24x7.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Css formatting problem beetle_jaipur CSS Cascading Style Sheets 2 June 5th, 2009 07:16 AM
Problem with formatting rakesh XSLT 10 July 23rd, 2008 05:54 PM
formatting problem everest ASP.NET 1.0 and 1.1 Professional 2 October 5th, 2005 09:59 AM
General formatting problem...... mike_remember ASP.NET 1.x and 2.0 Application Design 1 October 5th, 2004 09:18 AM
Query/formatting problem in report mega Access VBA 8 September 16th, 2004 04:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.