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

Using Access Objects in VB

Status
Not open for further replies.

impulse24

IS-IT--Management
Jul 13, 2001
167
US
How do i use the docmd in vb. I have an Access table, and I want to use the DoCmd.TransferText. I set a reference to Microsoft Access Object Library, . But don't know what to do next. Below is the code I have so far, but nothing is imported.

Dim IndexDb As Database
strDBName = "LCC" & Format(Now, "yyyymmdd")
OpenDatabase = "C:\Test\" & strDBName ".mdb"
DoCmd.TransferText acImportFixed, "ImportSpec", "Import", "C:\Index.txt", False, ""
Name "C:\Index.txt" As "C:\Index.done"
 
Here is a sample of a command button that exports a table to excel. It is very similar and should give you some pointers. I've used the common dialog control to allow the user to select the path to export to, so that really has nothing to do with the export itself. Hope this helps
Stacey

Dim strFileName As String
'export mailinglist table to excel
Dim MyApp As New Access.Application
On Error GoTo ErrHand
With CDExport
.CancelError = True
.Flags = cdlOFNOverwritePrompt + cdlOFNPathMustExist
.Filter = "Microsoft Excel Files (*.xls)|*.xls"
.FileName = ""
.DialogTitle = "Select Location for Export"
.ShowOpen
strFileName = .FileName
End With
MyApp.OpenCurrentDatabase strPath
MyApp.DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "ExportMailingList", _
strFileName

Set MyApp = Nothing
MsgBox "Export Completed.", vbOKOnly + vbApplicationModal + vbInformation, "Export Data"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top