Tylendal1
asked on
VB6 code to read mdb table and convert to csv file
I'm looking for code syntax that reads an mdb table and outputs it to a CSV file using VB6. I have been using Access and the docmd.TransferText to create a delimited file for export but am stumbling with the correct code to do the same in VB6. I'm thinking the process is simple but I'm a newbie to VB6.
Appreciat any assistance.
Appreciat any assistance.
ASKER
Hi matthewspatrick:
This is the code I have created in VB6 using your solution. I use "Call ExportVI_CSVData".
Sub ExportVI_CSVData()
Dim acApp As Object
mPathExport = "V:\MAS90\Home\TextOut\"
mFileExport = "UPS_MAS.CSV"
mPathMove = "v:\MAS90\"
Set acApp = CreateObject("Access.Appli cation")
With acApp
.OpenCurrentDatabase "V:\FRED\UPS_VInfo\UPS_VIn foVB.mdb"
.DoCmdTransferText acExportDelim, "UPS_Export", "UPSExport", _
mPathExport & mFileExport, False
.CloseCurrentDatabase
.Quit
End With
Set acApp = Nothing
End Sub
When executing the .DoCmdTransferText I get a run-time error '438':
Object doesn't support this property or method. Have i incorrectly applied your solution?
Thanks for your assistance.
This is the code I have created in VB6 using your solution. I use "Call ExportVI_CSVData".
Sub ExportVI_CSVData()
Dim acApp As Object
mPathExport = "V:\MAS90\Home\TextOut\"
mFileExport = "UPS_MAS.CSV"
mPathMove = "v:\MAS90\"
Set acApp = CreateObject("Access.Appli
With acApp
.OpenCurrentDatabase "V:\FRED\UPS_VInfo\UPS_VIn
.DoCmdTransferText acExportDelim, "UPS_Export", "UPSExport", _
mPathExport & mFileExport, False
.CloseCurrentDatabase
.Quit
End With
Set acApp = Nothing
End Sub
When executing the .DoCmdTransferText I get a run-time error '438':
Object doesn't support this property or method. Have i incorrectly applied your solution?
Thanks for your assistance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi...
The suggested modifications to your solution gaves me the same run-time error message '438': Object doesn't support this property or method
The suggested modifications to your solution gaves me the same run-time error message '438': Object doesn't support this property or method
Are you positive you have a specification in that database named UPS_Export?
Are you positive that your table is named UPSExport?
Are you positive that your table is named UPSExport?
ASKER
Hi again...
The USP_Export is the name of the export specification file used to output data from the table USPExport. I created the original application in Access2003 and just ported it to VB where I ran into the problem with the Docmd.TransferText.command .
I just executed the Access application and it works fine. Sorry for the headache this might be creating.
The USP_Export is the name of the export specification file used to output data from the table USPExport. I created the original application in Access2003 and just ported it to VB where I ran into the problem with the Docmd.TransferText.command
I just executed the Access application and it works fine. Sorry for the headache this might be creating.
Tylendal1 said:
>>Sorry for the headache this might be creating.
No worries--sorry I haven't figured it out :)
I think you should use the 'request attention' link to ask the Mods to add the Access zone and send out alerts, because
I am running out of ideas.
>>Sorry for the headache this might be creating.
No worries--sorry I haven't figured it out :)
I think you should use the 'request attention' link to ask the Mods to add the Access zone and send out alerts, because
I am running out of ideas.
ASKER
Not sure where the "request attention" link is located but one of my tags was Access 2003.
Fred
Fred
Fred,
Scroll to the top of the page. It should be in the block with your original question.
Patrick
Scroll to the top of the page. It should be in the block with your original question.
Patrick
I think that
.DoCmdTransferText
should be
.DoCmd.TransferText
=====
TransferText is a DoCmd method
.DoCmdTransferText
should be
.DoCmd.TransferText
=====
TransferText is a DoCmd method
Well spotted.
Thanks, aikimark. Darn typos :)
ASKER
Sorry we stumbled around on this Patrick. But once I added the "." and ran your solution again, it worked perfectly. Thanks for the help.
Fred
Fred
You can simply do this:
Dim acApp As Object
Set acApp = CreateObject("Access.Appli
With acApp
.OpenCurrentDatabase "path of MDB file here"
.DoCmdTransferText
.CloseCUrrentDatabase
.Quit
End With
Set acApp = Nothing
Regards,
Patrick