I have a music database that I am trying to export txt playlists from. The code would cycle through a table of dates and date codes (example: 7/1/1967; 19670701) to create a playlist with absolute file addresses. The problem I get when running isn't with the queries, but with the filename. My code is as follows:
The error I get from this is Run-time error '3125': '19670701.txt' is not a valid name. Make sure that it does not include invalid characters of punctuation and that it is not too long."
VBA Code:
Sub rundata()
Dim rs As DAO.Recordset, i As Long
Dim dt As String
Set rs = CurrentDb.OpenRecordset("pdates")
Do While Not rs.EOF
'DoCmd.RunMacro "macro1"
dt = "D:\music\Playlists\Charts\" & DLookup("[DtStr]", "[Chart Date]") & ".txt"
DoCmd.TransferText transferType:=acExportDelim, TableName:="Playlist 2", FileName:=dt, hasfieldnames:=True
DoCmd.OpenQuery "Delete Min Date"
'rs.MoveNext
Loop
MsgBox "Done"
Set rs = Nothing
End Sub
The error I get from this is Run-time error '3125': '19670701.txt' is not a valid name. Make sure that it does not include invalid characters of punctuation and that it is not too long."