944,052 Members | Top Members by Rank

Ad:
  • MS SQL Discussion Thread
  • Unsolved
  • Views: 5182
  • MS SQL RSS
Nov 28th, 2006
0

Access table data transfer to file

Expand Post »
Hi Guys,

I was just trying to transfer data from access tables to a txt file and then back from file into a table using following code



MS SQL Syntax (Toggle Plain Text)
  1.  
  2. Private Sub Command0_Click()
  3. DoCmd.TransferText acExportDelim, "Db Export Specification", "AUTHENTICATION", "J:\Power Equipment\Common\SK\db.TXT"
  4. End Sub
  5.  
  6. Private Sub Command1_Click()
  7. strSQL = "delete * from AUTHENTICATION_TEST"
  8. DoCmd.RunSQL strSQL
  9. DoCmd.TransferText acImportDelim, "Db Import Authentication Specification", "AUTHENTICATION_TEST", "J:\Power Equipment\Common\SK\db.TXT"
  10. End Sub

Is it possible to create and manipulate import/export specifications using the VBA code rather than the access manu so that I can make it work on different systems.

Thanks for your time
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
saurabh_kanwar is offline Offline
20 posts
since Sep 2006
Nov 30th, 2006
0

Re: Access table data transfer to file

Hi Saurabh,

It sounds to me like you require the ability to specify the Data-Type when importing fields into MSAccess, because sometimes MSAccess guesses the field types incorrectly.


I dont have the complete solution, but a suggested starting point.

The idea is to create a recordset (based on your SQL), and then read through it one record at a time. each record is then written to the textfile.

Theres a bit of code missing lol, this isnt a copy n paste solution my friend

Anyways, I hope I helped
good luck!


Private Sub Command0_Click()

'Create a Connection Object
'Create a Recordset object based on your SQL

Open "J:\Power Equipment\Common\SK\db.TXT" For Output As #1

While Not rst.EOF

Print #1, rst("ImageID") & vbTab & rst("ImageWidth" & vbCrLf)

Wend

Close #1

End Sub


Private Sub Command1_Click()
strSQL = "delete * from AUTHENTICATION_TEST"
DoCmd.RunSQL strSQL
DoCmd.TransferText acImportDelim, "Db Import Authentication Specification", "AUTHENTICATION_TEST", "J:\Power Equipment\Common\SK\db.TXT"
End Sub
Reputation Points: 10
Solved Threads: 0
Newbie Poster
TheDugglerrr is offline Offline
2 posts
since Oct 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in MS SQL Forum Timeline: Select Until ?
Next Thread in MS SQL Forum Timeline: mysql to msql data migration





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC