473,403 Members | 2,222 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

FORM to TXT, Query to TXT, current form to text file

gcoaster
117 100+
Hello Access Guru's

After pulling out most of my hair last year getting access to work the way I wanted it to to perform the simplest tasks, I am back at it and aim to not to pull out the rest!

What I am Aiming for
» I have a FORM that has a Query as its source.
» I want to create a cmd button on the form that exports the data on the current form to a txt file and then opens the or a txt file that has certain textbox values from the current form. ( reason for the form data is some of the texbox's have combined info from more then one textbox controls on form... for instance

Expand|Select|Wrap|Line Numbers
  1. Me.txtImageUrl = [txtImageHttp] & "" & Left([txtImageId], 3) & "/" & [txtImageId] & "" & [txtJpg]
» data in txt file is formatted in a way where each field value is on a separate line or | delimited.. you know, so it looks nice, nut just a dump seperated by commas,,,,
» More then one solution would be cool..
» and ah yes, Keep it simple.


thanks you guys are great.. M@
Feb 10 '09 #1
8 1787
DonRayner
489 Expert 256MB
As a start you could look at the OpenTextFile and OpenAsTextStream methods. Also check out the #write and #print statements.
Feb 10 '09 #2
gcoaster
117 100+
Google.com » site:bytes.com/topic/access/answers/ #print AND #write

yields all sorts of results... im starting to reach for my hair.

Examples anyone?

.
Feb 11 '09 #3
DonRayner
489 Expert 256MB
@gcoaster
Here is a quick example on how to use #print

Expand|Select|Wrap|Line Numbers
  1. Dim stName As String
  2. stName = "c:/test.txt"
  3. Open stName For Output As #1
  4. Print #1, Me.TextBox1
  5. Print #1, Me.TextBox2
  6. Print #1, Me.Textbox3
  7. Close #1
And #Write

Expand|Select|Wrap|Line Numbers
  1. Dim stName As String
  2. stName = "c:/test.txt"
  3. Open stName For Output As #1
  4. Write #1, Me.TextBox1
  5. Write #1, Me.TextBox2
  6. Write #1, Me.Textbox3
  7. Close #1
The #write will include quotes around the text and the #print won't. However I believe that with the #print there may be times that you need to do a Ltrim() to remove leading space. Replace the "Output" part with "Append" If you want to append to the end of an existing file.
Feb 11 '09 #4
gcoaster
117 100+
IT WORKS! IT WORKS

Very Cool, Very cool...

one more question,
It worked, but data is dumped and all scrunched together..
How would I add or rather insert a, lets say a return, <p></p>, line space if you may between each line? or a separator like --------------------
like this

contents of TextBox1
------------------------------------------------------
contents of TextBox2

contents of TextBox3



Or better yet, like this

NAME: | contents of TextBox1
------------------------------------------------------
ADDRESS: | contents of TextBox2

EMAIL | contents of TextBox3


AND what line of code would I use to open the Test.txt file after it exports?

thank you so much,
M@
Feb 12 '09 #5
gcoaster
117 100+
Hello All Figured some out on my own by searching this forum this way in google. ► site:http://bytes.com/groups/ms-access/ "Open File"

here is the Code so far

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdToText_Click()
  2. Dim stName As String
  3. Dim stOpenIt As String
  4.     stName = "C:\matt.txt"
  5.     Open stName For Output As #1
  6.     Print #1, "Name | ", Me.txtName
  7.     Print #1, Me.txtAddress
  8.     Print #1, "------------------------"
  9.     Print #1, Me.txtPhone
  10.     Print #1, Me.txtEmail
  11.     Print #1, ""
  12.     Close #1
  13.     OpenIt = Shell("C:\WINDOWS\Notepad.EXE C:\matt.txt", 1)
  14. End Sub
It works!!!

Print #1, "" ( inserts a Line )
Print #1, "------------------------" ( you guess it )
Print #1, "Name | ", ( puts text in front of Me.txtName.. like so» Name | Matt )
Declaring stOpenIt and then this line opens the text file
OpenIt = Shell("C:\WINDOWS\Notepad.EXE C:\matt.txt", 1)

All Right!!!
Hope this helps someone
M@V
Feb 12 '09 #6
DonRayner
489 Expert 256MB
I'm glad you got it working, Just let us know if we can supply you with any more help.
Feb 12 '09 #7
ChipR
1,287 Expert 1GB
This may be helpful also: Print and Display Constants. I just found it and I bookmarked it.
Feb 12 '09 #8
NeoPa
32,556 Expert Mod 16PB
You're using Print#. The Help topic gives some helpful techniques for this, and how best to understand what it's doing (limitations etc).

A few very basic tips :
  • The outputlist parameter(s) can be separated by a comma (,) or a semi-colon (;).
  • The comma will space out to the next tab position before printing the next data.
  • The semi-colon ensures no separation.
  • Unless there is a trailing semi-colon, a new line (vbCrLf) is always appended (Print #1 on its own simply adds a new line).
Feb 16 '09 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Michael Brennan-White | last post by:
If I submit my for using a get action the resulting page loads . If I use a post action I get an error page saying "The page cannot be found". I am calling the originating page!!! This happens...
3
by: Harvey | last post by:
Hi, I try to write an asp query form that lets client search any text-string and display all pages in my web server that contain the text. I have IIS 6.0 on a server 2003. The MSDN site says...
1
by: kyma via .NET 247 | last post by:
Hi, I haveto use VB to create a form that reads an exisiting XML fileand then allows updates via the VB form. My problem is that I was able to get VB to read a simple XML file(people.XML), but...
1
by: Marcia | last post by:
I have a combobox for types of music and a combobox for artists. The rowsource query for the artists combobox associates artists with different types of music. In the query I use the name of the...
25
by: Lyn | last post by:
Hi, I am working on a genealogy form. The only table (so far) lists everybody in the family, one record per person. Each record has an autonum ID. The parent form (frmMainForm) displays the...
8
by: david.lindsay.green | last post by:
Hello all, I am quite new a web scripting and making web pages in general and I have stumbled across a problem I have as yet been unable to solve. I am trying to take the contents of a textarea box...
25
by: artromanov | last post by:
Hello everyone. I am somewhat new to access and this forum. Hopefully it will be a great and helpful experience. My problem is this. I have a database (about 65,000 records). I get a run from...
4
by: Susan Bricker | last post by:
I have a form that displays record information in Continuous Record display (scrollable list). One of the fields in the record is an Integer value called "rcode" (reason code). But, I don't want...
3
by: jambonjamasb | last post by:
Hi I have two tables: email_tbl Data_table Data table is is used to create a Form Data_form
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.