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

Dynamic File location problem

Status
Not open for further replies.

Beards247

IS-IT--Management
Jan 15, 2007
2
US
In theory its really simple - run a query, export the results to a file location. When the file location is based on a variable the export fails (The manually written location is the same as the variable location)- tells me:
Run-time error '3027':

Cannot update. Database or object is read-only.

The little bit of searching online shows a couple issues with openrecordset... do I need to open the table first or something?

Code:
Private Sub MBA_VBA_Click()
DoCmd.SetWarnings (warningsoff)
Dim uploaddate As String
Dim uploadtype As String
Dim fileName As String
uploaddate = Format(Now(), "yyyymmdd")
uploadtype = "MBA"
fileName = "O:\OUR Uploads\" & uploaddate & "_" & uploadtype & " .txt"
DoCmd.OpenQuery ("Q_Our_Upload_Base_MBA_Final")
DoCmd.Close acQuery, "Q_Our_Upload_Base_MBA_Final"
If MsgBox("Ready to Export the MBA Upload?", vbOKCancel, "OUR Upload") Then

' DoCmd.TransferText acExportFixed, "Our_Upload Export Specification", "OUR_Upload", "fileName"
DoCmd.TransferText acExportFixed, "Our_Upload Export Specification", "OUR_Upload", "O:\OUR Uploads\20070510_mba.txt"

Else
Exit Sub
End If
' Open query that will append all sent records along with who sent and on which date

MsgBox ("The data has been exported to " & fileName & ". Continue with Upload process.")

End Sub
 

Minor adjustement, no " at file name variable..

DoCmd.TransferText acExportFixed, "Our_Upload Export Specification", "OUR_Upload", fileName
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top