View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Automating Making a DBF File

for people who haven't read your previous posting all we are doing is a
"SAVEAS" an excel file into DB4 format. The Excel worksheet has 10
characters and when the Dbase4 reads the data is is only finding 9 characters.

The problem is either excel is dropping the last character or Dbase4 isn't
reading the last character. Excel shoud be treating the key as a string and
I don't believe excel is trucating a trailing character, but you never know
with excel.

I would think the problem is that the dbase4 database really only has a 9
digit key. You may just have to remove the last character in the excel
worksheet before saving. I suspect the last character isn't an ID but a
sequence number that just need to be removed. Open the dbase4 database and
make sure it wants only nine characters and not ten characters.

"Bob Barnes" wrote:

Got great code from Joel last week, but now looking at...

Column L in the DBF is what makes the Row (Record) Unique.

Column L in the Daily excel file is a "mixture" of Entries w/ 9 or 10
characters. I know when making a DBF Manually from Excel, that Excel looks
at the first few rows to "guess" what DataType it is, and number of
characters.

Working w/ this particular file, Excel has to be "guessing" it's 9
characters instead of the actual (example) 10 characters below.

MSR0332476
MSR0332489
MSR0332488
MSR0332486

So...the DBF results in...
MSR033247
MSR033248 -- Can't be a Primary Key
MSR033248 -- Can't be a Primary Key
MSR033248 -- Can't be a Primary Key

Is there a way to use VBA to set the number of characters
in the DBF's Column L to 10-characters?

TIA - Bob