问题描述
请我是VBA访问数据库的新手,我的后台编程语言一直专注于C#
我有一个任务是启动一个特定的文件名(所有文件)在doc,xls等中,当用户点击每个特定文件名的按钮时,从相同的目录路径。
我一直在谷歌搜索并使用不同的方法仍然它好像不起作用。
我试过这个:
Please I am new in VBA access database and my background programming language has been focused on C#
I have a task to launch a specific file name (all files in doc, xls, etc) from the same directory path when the user click on a button for each specific file name.
I have been googling and used different approach still it seemed not to work.
I tried this:
Private Sub FileMsReports_Click()
Dim f As Object
Set f = Application.FileDialog(3)
f.AllowMultiSelect = True
If f.Show Then
For i = 1 To f.SelectedItems.Count
sFile = FileName(f.SelectedItems(i), sPath)
MsgBox sPath & "---" & sFile
Next
End If
End Sub
Public Function FileName(ByVal strPath As String, sPath) As String
sPath = Left(strPath, InStrRev(strPath, "\"))
FileName = Mid(strPath, InStrRev(strPath, "\") + 1)
End Function
我最终得到了一个文件对话框,但实际上并不是我的主管要我做的事情!
我仍然不喜欢编程的一年,现在这是我的实习地点的任务。
我需要有人帮助我并指导如何去关于这个。
提前谢谢。
I ended up getting a file dialog show up but it is not actually what my supervisor wanted me to do!
I am still like less a year in programming and right now this is a task giving to me for the place of my Practicum.
Please I need someone to help me out and direction on how to go about this.
Thanks in advance.
推荐答案
- []来存储文件名
- Create table[^] to store file names
CREATE TABLE MyFiles (MyFile CHAR);
OnClick
事件 MyFiles
table EnumMyFiles
OnClick
event MyFiles
tableEnumMyFiles
Private Sub EnumMyFiles()
'body of the procedure
End Sub
EnumMyFiles
程序体内:- 使用清除ListBox [] property
- Inside the body of
EnumMyFiles
procedure: - Clear ListBox using RowSource[^] property
Listbox.RowSource = ""
DELETE * FROM MyFiles;
DoCmd.RunSQL "INSERT INTO MyFiles (MyFile) VALUES('" & sFileName & "');"
LisBox.RowSource = "MyFiles"
Button_Click
过程调用 EnumMyFiles
procedure Button_Click
procedure call EnumMyFiles
procedurePrivare Sub Button_Click()
EnumMyFiles
End Sub
这篇关于如何使用单击按钮找到文件名并从MS Access 2007中的文件路径启动它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!