date creation property vba (1 Viewer)

Kuhn

Registered User.
Local time
Yesterday, 16:03
Joined
Oct 21, 2013
Messages
17
hi all,

I would like to find a solution for the following problem:
on a form I have a command button to load a subform, based on a certain table. the table is an imported table, with saved import procedure.
when clicking the button I want access to check the date of creation of the table and if it's <> current date, run the import procedure.
I've come up with this function to check the date, but it doesn't do the trick.

Code:
Public Function toplevelcheck()
If CurrentDb.TableDefs("table_FOX").Properties("DateCreated").Value <> Date Then
MsgBox "update table"
    DoCmd.RunSavedImportExport "Import-New Selection 1"
End If

End Function

what am I doing wrong?
 

Roku

MBCS CITP
Local time
Today, 00:03
Joined
Sep 26, 2013
Messages
112
DateCreated contains date and time, so it will not match with Date. A simple way to achieve the check is to take the integer part of DateCreated for the comparison, like this:
Code:
If Int(CurrentDb.TableDefs("tFiles").Properties("DateCreated").Value) <> Date Then
 

pr2-eugin

Super Moderator
Local time
Today, 00:03
Joined
Nov 30, 2011
Messages
8,494
Hello Kuhn, Welcome to AWF.. :)

The problem is the DateCreated has a Time value stuck to it.. So try..
Code:
Public Function toplevelcheck()
    If [URL="http://www.techonthenet.com/access/functions/date/datevalue.php"]DateValue[/URL](CurrentDb.TableDefs("table_FOX").Properties("DateCreated")) <> Date Then
        MsgBox "update table"
        DoCmd.RunSavedImportExport "Import-New Selection 1"
    End If
End Function
 

Kuhn

Registered User.
Local time
Yesterday, 16:03
Joined
Oct 21, 2013
Messages
17
superb - works fine now. thanks for the quick help!
 

Users who are viewing this thread

Top Bottom