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

Sending information to a ODBC database

Status
Not open for further replies.

Pinan

IS-IT--Management
Jul 15, 2002
40
US
This is the code that I was given to retrieve information from a database.

EDWInfo_Open strPullSQL, Cnxn, adOpenForwardOnly, adLockReadOnly, adCmdText

lblBigOut.Caption = ""

Do Until EDWInfo.EOF
Do Until EDWInfo.EOF
lblBigOut.Caption = lblBigOut.Caption & Trim(EDWInfo.Fields(0)) & Space(15 - Len(Trim(EDWInfo.Fields(0)))) & EDWInfo.Fields(1) & Space(15 - Len(Trim(EDWInfo.Fields(1)))) & EDWInfo.Fields(2) & vbCrLf
EDWInfo.MoveNext
Loop
Loop

It works beautifully. However, I need to manipulate it so that it sends info to file. Any ideas?
 
Try this:

EDWInfo_Open strPullSQL, Cnxn, adOpenForwardOnly, adLockReadOnly, adCmdText
dim text_var as string
free_file=freefile
open "file1.txt" for output as free_file
lblBigOut.Caption = ""

Do Until EDWInfo.EOF
Do Until EDWInfo.EOF
lblBigOut.Caption = lblBigOut.Caption & Trim(EDWInfo.Fields(0)) & Space(15 - Len(Trim(EDWInfo.Fields(0)))) & EDWInfo.Fields(1) & Space(15 - Len(Trim(EDWInfo.Fields(1)))) & EDWInfo.Fields(2) & vbCrLf
text_var=lblBigOut.Caption
print free_file,text_var
EDWInfo.MoveNext
Loop
Loop
close free_file

This should write the contents out to a text file called file1.txt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top