Katya85S
Programmer
- Jul 19, 2004
- 190
I'm pulling data from .inf file to MS Access table.
The application searches through .inf files, finds a key words, indicating, that the data between the key-words needs to be extracted into Access as Date/Time field and extracts this value. Let's say the value is assigned to VBA variable strDate.
I should mention, the data in .inf file is stored in yyyymmdd format, so it looks like 20070201.
To insert it to my datetime field in teh table i have to format it (perhaps, there is a better way, so please advice):
strDate = CDate(DateSerial(Left(strDate , 4), Mid(strDate , 5, 2), Right(strDate , 2)))
strDate = Format(strDate , "mm/dd/yyyy")
From time to time it happens that there is no data between the key-words, and then the extracted value is "".
Then i get an error "Type mismatch" on
strDate = CDate(DateSerial(Left.... Line.
I've tried to avoid this line if strDate="", leaving strDate unformatted for strDate="". I still could not execute insertion. This time an error was "Data type conversion error".
How can i fix it?
Thank you all in advance.
The application searches through .inf files, finds a key words, indicating, that the data between the key-words needs to be extracted into Access as Date/Time field and extracts this value. Let's say the value is assigned to VBA variable strDate.
I should mention, the data in .inf file is stored in yyyymmdd format, so it looks like 20070201.
To insert it to my datetime field in teh table i have to format it (perhaps, there is a better way, so please advice):
strDate = CDate(DateSerial(Left(strDate , 4), Mid(strDate , 5, 2), Right(strDate , 2)))
strDate = Format(strDate , "mm/dd/yyyy")
From time to time it happens that there is no data between the key-words, and then the extracted value is "".
Then i get an error "Type mismatch" on
strDate = CDate(DateSerial(Left.... Line.
I've tried to avoid this line if strDate="", leaving strDate unformatted for strDate="". I still could not execute insertion. This time an error was "Data type conversion error".
How can i fix it?
Thank you all in advance.