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
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