Function NextFileName() Dim fileprefix As String*1 Dim tempNextFileName As String Dim txtFilePath As String Dim strYYYYMM as String*6 strYYYYMM = Format(Now(),"yyyymm") txtFilePath = "c:\exported_data\" fileprefix = "A" Do While True tempNextFileName = txtFilePath & fileprefix & _ strYYYYMM & ".txt" If Dir(tempNextFileName) = "" Then Exit Do End If fileprefix = Chr(Asc(fileprefix) + 1) Loop NextFileName = tempNextFileName End Function