Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

flatfile-db ---> access-db problem. NEED HELP!

Status
Not open for further replies.

allert

Technical User
Apr 11, 2006
1
NL
Trying to write a script that converts a (used cars) flat-file-database to an Access-database, I keep running into the following problem:

The original, flat-file-db, looks like this:
id|mark|type|field4|field5|field6|PRICE|field8 etc.
Using the FileSystemObject, the script reads the lines and, using MyArray = Split(strLine,"|"), puts the values in an array. After that, the script assigns the values to their respective access-db-fields: rst("Mark") = MyArray(1) etc. All fields go well, except for the PRICE field. This is the only field that is declared as being numeric in Access, but I didn't think that had to be a problem. As it turns out, it is. rst("Price") = MyArray(7) doesn't work, whereas manually assigning a 'string' type value to it does: rst("Price") = "17950" works fine. But that's useless, as you'll all understand.

My question: how on earth can I solve this problem? It's really important, because otherwise I will have to manually insert hundreds of cars in the Access-db ;-)
 
Have you tried converting to numeric for that field? Assuming that the field is a long integer, the syntax would be
rst("Price") = CLng(myarray(7))
 
Allert,

I almost ALWAYS do import of 'stuff' as text. This does not impose conditions on the 'stuff' I'm trying to get. After it is loaded into MS Access, you can do any conversion necessary. Often, even changing field types from text to numeric can be accomplished within an existing table - provided you have reviewed the data and 'fixed' any problems. It is relatively easy to groom the imported data via queries which check the data via criteria like "IsNumeric" ...

 
Why dont you just use the import features that are included in access. They allow you to assign data types at the time of import using a wizard.

Unless theres something I missed in your post that would prevent you from doing this.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top