The Code that I have despatched to you will work, provided you do the following.

Open an new exe project.

create a form with one command button.
Pull down the top menu, project
select references.
4 things are defaultly checked for you.
They are
1. Visual Basic for Application
2.Visual Basic runtime object and procedures
3.Visual Basic Objects and Procedures
4. OLE Automation.

Corecct?

Then You browse through the list by pressing the down arrow key, where you will land up in Microsoft ActiveX Data Objects 2.5 Library.
check the box left of it and press ok.

again pulldown the project menu, select references and see whether the Microsoft ActiveX Objects 2.5 Library is checked as the 5th one.
If so click ok.

If this library is not there in your system, try to select a nearest version.
ie, 2.1,2.6,2.7,2.8 any one of them or all
click ok

you are once again on the form window where you have created the command button.
on the rightside pan click the leftmost rectangle(white) for code view.
The Form_load Sub will be there and your cursor blinking in between
the sub and the end sub
Cut and past my code there.
The last line will be a second end sub. Delete it.

Now just run the program by clicking the statrt (arrow head).

Report to me whether any compile error it is giving, if yes, please tell me on what piece of code.

bravo Go ahead!

Happy programming

AV Manoharan

heey big B
it is workin fine noww.really.great and thanx a million from core of my heart.
no of records = no f txt files generaated.but it s generatin one txt ffile.


with regards
suneel kaaar

See the piece of code below.
this will take care of your no of records=no of lines.
cut and paste over the earlier Do and Loop code.

Do While Not rs.EOF
For i = 0 To rs.Fields.Count - 2
If rs.Fields(i) = Null Then
tstream.Write (",")
Else
tstream.Write (rs.Fields(i) & ",")
End If
Next
if rs.fields(i)<>null then
tstream.write(rs.fields(i))
Else
tstream.write(",")
End if
tstream.WriteLine (Chr(13))
rs.MoveNext
Loop

regards
AV Manoharan

bro
i wanna talk to u bro on gmail.
add me in ur gmail account.
regards
suneel

no of txt files= no of records
brrother

Dim DB As Datbase
Dim RST As RecordSet
Dim sSQL As String
Set DB = DBEngine.OpenDatabase("C:\MyDBFFolder\folder1", False, False, "dBASE III;")
sSQL= "Select * From MyTable"
Set RST= DB.penRecordset(sSQL)

and what if the next I want to access folder2 for example

Dim DB As Datbase
Dim RST As RecordSet
Dim sSQL As String
Set DB = DBEngine.OpenDatabase("C:\MyDBFFolder\folder2", False, False, "dBASE III;")
sSQL= "Select * From MyTable"
Set RST= DB.penRecordset(sSQL)

How am i going to code for that?

hi Veena,

Thanks for this post. I tried your code above but I get an error "Too few parameters. Expected 4."

Set rs = DBEngine.OpenDatabase("***\AD1\", False, False, "dBASE III;").OpenRecordset(SQL, dbOpenSnapshot)

Can you please help me fix this one. I am fairly new to VBA.

Thanks,
Pappu.

Hi Veena,

I kind of figured the problem.It was an issue with my query. I fixed my query and everything seems to work.

Thanks,
Pappu.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.