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

Transferring records from an Open form to Textfile 1

Status
Not open for further replies.

JamesBBB

Technical User
Nov 2, 2005
74
GB
Hi All,

A quick question re transfering text. Basically I have a "continuous" form that has a number of records that has been filtered by the user so that they see only what they want to see.

what I would like to do is have a button that would export the records on the screen to either a text file or an excel spreadsheet.

I have experimented with the Docmd.transfertext command, but that seems to deal only with tables and queries and not what is actually showing on the open form.

Is this possible, any help would be gratefully received.

many thanks

James
 




Hi,

You might be better off posting in Forum702.

Skip,
[sub]
[glasses] To be safe on the [red]FOURTH[/red],
Don't take a [red]FIFTH[/red] on the [red]THIRD[/red]
Or you might not come [red]FORTH[/red] on the [red]FIFTH[/red]
[red][highlight blue]FORTH[/highlight][/red][white][highlight red]WITH[/highlight][/white] [tongue][/sub]
 
JamesBBB,
Something like this should work.
Code:
Private Sub Command1_Click()
Dim objWorkbook As Object
Set objWorkbook = CreateObject("Excel.Sheet")
objWorkbook.workSheets(1).Range("A2").CopyFromRecordset Me.Recordset
objWorkbook.SaveAs "C:\FormRst.xls"
objWorkbook.Parent.Quit
Set objWorkbook = Nothing
End Sub

Hope this helps,
CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
Thanks CautionMP

Apologies for the late thanks and acknowledgement, I have been away this weekend. Ill give it a go this evening and let you know how I get on

Many thanks

James
 
Hi CautionMP

Absolutely, fantastic, works perfectly

thanks

James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top