如何将 # 附加到 MS Access 附件字段中的文件名(如果存在)
您好,我的 Access DB 表单中有 4 个附件字段和 2 个文本框。 (txt_文件1,txt_目标1) 一个文本框用于源文件,另一个文本框用于目标文件。 我试图弄清楚如果文件存在,如何将 # 附加到文件名。 目前它只是覆盖现有文件。
前任。
办公室安全培训_Cert_dnye_2022-03-18
办公室安全培训_Cert_dnye_2022-03-18(2)
办公室安全培训_Cert_dnye_2022-03-18(3)
Office Safety Training_Cert_dnye_2022-03-18(4)
我想可能是一个循环递增一个整数,并将该整数附加到文件名中? 文件名由名为“标题”的文本框字段+访问用户名+日期组成。
这是我检查文件是否存在的方法:
文件存在模块:
Public Function FileExists(ByVal path_ As String) As Boolean
FileExists = (Len(Dir(path_)) > 0)
End Function
我在想这个 如果文件存在,我想将 # 附加到目标文本框文本 否则只需正常设置目的地:
If FileExists(txt_dest1) Then
'MsgBox ("File Exists")
Else
Me.txt_dest1.Text = DestFolder1 & "\" & txt_Title.Value & "_" & "Cert" & "_" & TempVars![GlbUserName] & "_" & Format(Date, "yyyy-mm-dd") & ".pdf" 'GetFilenameFromPath(vrtSelectedItem) & "\"
End If
Hi I have 4 attachment fields in my form in my Access DB, and 2 textboxes. (txt_file1, txt_dest1)
One textbox for the source file and another for the destination file.
I am trying to figure out how to append a # to the filename if the file exists.
Currently it is just overwriting the existing file.
Ex.
Office Safety Training_Cert_dnye_2022-03-18
Office Safety Training_Cert_dnye_2022-03-18(2)
Office Safety Training_Cert_dnye_2022-03-18(3)
Office Safety Training_Cert_dnye_2022-03-18(4)
I am thinking maybe a loop incrementing an integer, and append that integer to the filename?
The filename is made up of a textbox field called "title" + access username + the date.
Here is how I am checking to see if the file exists:
File exists module:
Public Function FileExists(ByVal path_ As String) As Boolean
FileExists = (Len(Dir(path_)) > 0)
End Function
I was thinking this
if the file exists, I want to append a # to the destination textbox text
otherwise just set the destination normally:
If FileExists(txt_dest1) Then
'MsgBox ("File Exists")
Else
Me.txt_dest1.Text = DestFolder1 & "\" & txt_Title.Value & "_" & "Cert" & "_" & TempVars![GlbUserName] & "_" & Format(Date, "yyyy-mm-dd") & ".pdf" 'GetFilenameFromPath(vrtSelectedItem) & "\"
End If
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论