Hi, sorry I didn't reply yesterday.
I've tried to use your advice. This happend.
runtime error 2501 - OutputTo event has been canceled
Code:
Option Compare Database
Private Sub cmd_cz__rozsirene_Click()
Dim MyDB As DAO.Database
Dim MyRS As DAO.Recordset
Dim strSQL As String
Dim strRptName As String
Dim count As Integer
strRptName = "Cz_Tisk_rozsirene"
strSQL = "Select q_filtrCzTisk_rozsirene.[SampleId], q_filtrCzTisk_rozsirene.[Village] From q_filtrCzTisk_rozsirene;"
Set MyDB = CurrentDb
Set MyRS = MyDB.OpenRecordset(strSQL, dbOpenForwardOnly)
With MyRS
Do While Not MyRS.EOF
DoCmd.OpenReport strRptName, acViewPreview, , "[SampleId]='" & ![SampleId] & "'"
DoCmd.OutputTo acOutputReport, strRptName, acFormatPDF, "C:\_pokusne\datab\" & ![Village] & "\" & ![SampleId] & ".pdf", False
DoCmd.Close acReport, strRptName, acSaveNo
.MoveNext
Loop
End With
MyRS.Close
Set MyRS = Nothing
End Sub
if I delete "\" in outputfile and try to export - it is working, but name of village appears in the name of file.
My problem is how to write the code to achieve creating subdirectorie using village field. Any Ideas?
Anyway I am gratefull for your help. Thank You.