I have applications I wrote that are very similar in the sense that I am
importing data from a non-Access application (like Excel or text file), and
the integrity of the data types are not reliable. For instance, a date field
that has non-datable info (such as 'Not Known instead of a true date). What I
do is create 2 tables of identical structure except 1 has all text fields and
the other has the various numeric, date and other field types as necessary. I
import the data into the all-text table. I run queries to update the bad data
to null and convert to my preferred format otherwise. Example:
DoCmd.RunSQL "UPDATE CharityTable SET [Date Of Birth] = Null " _
& "WHERE Not IsDate([Date Of Birth])"
and:
DoCmd.RunSQL "UPDATE CharityTable SET [Date Of Birth] = " _
& "Format([Date Of Birth], 'mm/dd/yyyy')"
Then do similar representation of the above 2 queries to other sensitive
fields. After all that is complete, I transfer the data from the all-text
table to the other table and there you have your data in the format you like.
If I understood the issue correctly, that should do the trick
Bald Eagle said:
Thanks for the further guidance.
The Macro which I have developed is used to import an MS Excel spreadsheet
which contains the monthly Bank details of the Charity which have been
downloaded from the internet. Unfortunately the data needs to be converted
to make it usable in Access.
The Date field simply contains a string of numbers and dots and my Query
converts this into Date format although the field is showing up as a ‘Text’
field. This is where I used SendKeys to change it to Date format (d-mmm-yy).
There are also 2 money fields which are simply in ‘Number’ format. This was
my second use of SendKeys. However someone here has suggested that I could
use ‘CCur’ in the Query and I have done this and it works on my PC – I
haven’t had an opportunity to try it on the Vista laptop, do you think this
should work OK on it?
Lastly I create a new field from the ‘Details’ field in the spreadsheet to
hold the Cheque numbers for reconciliation purposes. However this is also
showing as a ‘Text’ field in the Access Table. This was my final use of
SendKeys.
Is there anything similar to CCur which I could use in the Query to make the
first ‘Text’ field into ‘Date’ with d-mmm-yy format and the second ‘Text’
field into ‘Number’ format?
It’s great that there is such a wealth of expertise out there which I can
tap into! I must use it more often when I hit a brick wall!