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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Flat File Created By C Program Can't Be Read From MSAccess

Status
Not open for further replies.

jtrapat1

Programmer
Jan 14, 2001
137
0
0
US
I have a C Program which writes out a fixed length file.
The file needs to be read by a macro in Microsoft Access which expects the data in fixed starting and ending positions.

However, when I try to import the file from Access, by:
Get External Data...
and then choose the file; the import only loads the first record of a large file.
When I step thru the access wizard, all of my fields match up with the file layout but still I only import one record.

I found one way around this to successfully import the file:
If I save the file as type "PC", then the file imports completely; but my problem is that I need to do this thru code, from C.
Is there any way of achieving this?
I opened the text file in an editor and somehow my program is inserting a blank line between each record.

Am I doing something wrong in the formatting of this file?
Here's the output statement where I write out the file from the C Program:
I do include a carriage return and line feed.
------------------------------------------------
fprintf(output,"%5li%-80s%-80s%-80s%-80s\r\n",
bp12.adds_id, cmnt1, cmnt2, cmnt3, cmnt4);

------------------------------------------------

Maybe my access macro is inserting an extra blank line between each record. How can I turn this off in access?

Can anyone help?
Thanks in Advance

John
 
You could try losing the return \r
As you didn't mention how the file was opened, if it is not in binary mode the \r is not required and will insert an extra return that Access may not like.

fprintf(output,"%5li%-80s%-80s%-80s%-80s\n",
bp12.adds_id, cmnt1, cmnt2, cmnt3, cmnt4);




 
DucatiST2,
Thanks for the help.

That fixed the problem.

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top