会员登录 - 用户注册 - 网站地图 Office中国(office-cn.net),专业Office论坛
当前位置:主页 > 技巧 > Access技巧 > 模块函数VBA > 正文

[技巧分享]Access自动生成按日期递增的文件名

时间:2013-07-09 08:43 来源:Office中国 作者:tmtony 阅读:
自动生成按日期递增的文件名


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

(责任编辑:admin)

顶一下
(2)
100%
踩一下
(0)
0%
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价: