Jurgen Welz
jwelz at hotmail.com
Sun Jul 13 16:30:22 CDT 2008
I have users who need to assemble a series of Material Safety Data Sheets, MSDS, provided by suppliers of products. The documents supply information about the hazards of the products. Users download these documents from supplier websites or scan them from hard copy and save them to a folder. I allow my users to select applicable MSDS for a project by displaying a multi select list box. Each MSDS has an expiry date that is 3 years from the date of issue. I don't like to store information about the MSDS separate from the files, but prefer to allow the files to speak for themeselves. VBA provides a simple way to read the file date with the function FileDateTime. Pass it a file path and name and it returns a date data type. Once the group of files is selected, a copy of each is moved to a project folder and the date is checked. My procedure returns a message advising which MSDS are expired and which will expire within the next three months. This information is used to ensure that updated MSDS are obtained. In order for this to work, my users import any new MSDS documents into the target folder containing all the MSDS. Part of the import procedure calls a procedure that sets the file attributes to the expiry date of the MSDS. My users also set the millisecond portion of the date to the number of pages in each file so that a table of contents with correct pagination is generated as part of the procedure. All this is transparent to the users so they don't know that they are changing file attributes. The beauty of this approach is that no data needs to be stored anywhere other than with the files themselves. New MSDS are automatically available for user selection by simply importing them into a folder and using the file attributes to store pertinent meta data easily accessible by VBA. Given the GMT issue, I set the hour flag to 19 (Mountain Standard Time) and the file time is noon or 1:00 PM depending on whether daylight savings time applies at the date. The declares, constants and sub below are what I have been using to set the file date: Private Declare Function OpenFile Lib "kernel32" (ByVal lpFileName As String, _ lpReOpenBuff As OFSTRUCT, ByVal wStyle As Long) As Long Private Declare Function SystemTimeToFileTime Lib "kernel32" (lpSystemTime As SYSTEMTIME, _ lpFileTime As FILETIME) As Long Private Declare Function SetFileTime Lib "kernel32" (ByVal hFile As Long, lpCreationTime As FILETIME, _ lpLastAccessTime As FILETIME, lpLastWriteTime As FILETIME) As Long Public Declare Function CloseHandle Lib "kernel32" (ByVal hFile As Long) As Long Public Const MAX_PATH = 260 Public Const OF_READWRITE = &H2 Private Type OFSTRUCT cBytes As Byte fFixedDisk As Byte nErrCode As Integer Reserved1 As Integer Reserved2 As Integer szPathName(MAX_PATH) As ByteEnd Type Public Type SYSTEMTIME wYear As Integer wMonth As Integer wDayOfWeek As Integer wDay As Integer wHour As Integer wMinute As Integer wSecond As Integer wMilliseconds As IntegerEnd Type Public Type FILETIME dwLowDateTime As Long dwHighDateTime As LongEnd Type Public Sub SetFileDateTime(strFile As String, dte As Date) Dim hFile As Long Dim OFS As OFSTRUCT Dim st As SYSTEMTIME Dim nt As FILETIME hFile = OpenFile(strFile, OFS, OF_READWRITE) With st .wYear = DatePart("yyyy", dte) .wMonth = DatePart("m", dte) .wDay = DatePart("d", dte) .wHour = 19 .wMinute = 0 .wSecond = 0 End With SystemTimeToFileTime st, nt SetFileTime hFile, nt, nt, nt CloseHandle hFileEnd Sub CiaoJürgen WelzEdmonton, Albertajwelz at hotmail.com> From: lembit.dbamail at t-online.de> To: accessd at databaseadvisors.com> Date: Sat, 12 Jul 2008 22:40:03 +0200> Subject: [AccessD] File Attributes> > Hi all,> In Access 2002 I want to modify the date/time created/modified of a lot of > files.> There are properties like .DateLastModified in the > Scripting.FileSystemObject.> However they are all read-only.> Is there a way how to modify these dates in Access 2002?> > I need this for changing the time of digital photos by 1 or 2 hours due to > timezone changes.> > thank you> Lembit _________________________________________________________________ Find hidden words, unscramble celebrity names, or try the ultimate crossword puzzle with Live Search Games. Play now! http://g.msn.ca/ca55/212