Ms Access浏览文件,复制到DB路径,在DB Path中创建文件的超链接 [英] Ms Access Browse for file, copy to DB path, Create hyperlink for file in DB Path

查看:84
本文介绍了Ms Access浏览文件,复制到DB路径,在DB Path中创建文件的超链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在服务器端设置MS Access DB,用户可以将他/她的本地文​​件附加(超链接)到所有用户都可以看到文件的数据库,因此它应该从他/她上传所选用户的文件计算机到服务器和服务器将其从当前数据库路径更改为超链接。我已找到并更改此代码,通过打开文件对话框来选择文件(它将文件上传到DB路径中的FILES文件夹),然后打开超链接对话框以从文件中选择文件。数据库路径中的文件夹。我想删除第二个对话框(超链接),用户只需从他/她的计算机中选择一个文件,超链接将构建并实际添加到表单中的所需对象。

I am trying to setup a MS Access DB in server side, users can attach (hyperlink) his/her local files to DB that all users can see files, so it should upload selected user''s file from his/her computer to server and server change it to a hyperlink from current DB path. I''ve found and change this code to do this by open file dialog to select file ( it''s uploading file to "FILES" folder in DB path ) and then open hyperlink dialog to select file from "Files" folder in DB path.i want remove 2nd dialog box (hyperlink) and user just pick a file from his/her computer and hyperlink will build and add pragmatically to desired object in form.

展开 | 选择 | Wrap | 行号

推荐答案

1)您发布的代码有一些小错误,请按照故障排除步骤找到这里: https://bytes.com/forums/feedback/91 ... g-vba-sql-code 你需要代表吃调试编译,直到它没有错误。调试器在发现的第一个错误时停止。


2)如果我理解正确:


+用户打开对话框

+选择文件


+选择

++你是在网络路径上将文件复制到网络第28行给出

...>>>我强烈建议不要直接在函数中为 FileCopy()构建字符串!

... a)这样做使得无法如果字符串格式错误,请正确排除故障。

... b)一旦函数完成,字符串就消失了......你不能重复使用它。

+ +你想将UNC存储为单元格中直接复制到网络中的文件作为超链接。


3)首先让我们来看看超链接字段是什么看起来像:

(allen browne再次救援!) 超链接字段简介


从上述文章中我们看到我们需要
显示文字#文件名#文件中的任何引用


注意使用#作为分隔符...当您尝试将字符串存储到超链接字段时,路径中包含此符号的任何地址都会导致错误。


因此构建字符串并将其存储到超链接字段....

>您需要当前在代码的第28行中构建的文件位置

> (可选)您需要一个显示文本,例如文件名。


使用上述模板构建一个字符串。


更新你的记录集'带字符串的超链接字段。


所以说你的用户选择了:

C:\ Users \< username> \Documents \示例PSFile.ps1


并且您已将其复制到

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ CursorRefresh。 ps1


然后最基本的字符串将是

"#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ CursorRefres h.ps1#"


如果您希望在字段中显示文件名:

" CursorRefresh.ps1#\\ server \Users\< username> \Docum ents \CursorRefresh.ps1#"


通过记录集添加/更新或更新动作查询方法。



>>这预先假定你的表格中有一个字段用作超链接字段。
1) Your posted code has some minor errors, please follow the basic trouble shooting steps found here:https://bytes.com/forums/feedback/91...g-vba-sql-code you will need to repeat the debug compile until it does so without errors. The debugger stops on the very first error it finds.

2) If I understand correctly:

+ User opens the dialogbox

+ Selects the file

+ upon selection
++ you are copying the file to the network on the network path given in Line 28
...>>> I highly advise not to build your string for the FileCopy() directly in the function!
...a) Doing so makes it impossible to properly trouble-shoot if there is a malformed string.
...b) Once the function completes, the string is gone... you cannot reuse it.
++ you want to store the UNC for the file copied to the network in the cell directly as a Hyperlink.


3) First lets take a look at what a hyperlink field looks like:
(allen browne to the rescue again!) Introduction to Hyperlink fields

From the afore mentioned article we see that we need
display text # file name # any reference within the file

Note the use of the "#" as a separator... any address containing this symbol in the path will cause you errors when you try to store the string to the hyperlink field.

So build your string and store it to the hyperlink field....
> You need the file location currently being built in Line28 of your code
> Optionally you need a display text such as the file name.

Build a string using the aforementioned template.

Update your record-set''s hyperlink field with the string.

so say your user selected:
C:\Users\<username>\Documents\ExamplePSFile.ps1

and you''ve copied it to
\\server\Users\<username>\Documents\CursorRefresh. ps1

then the most basic string would be
"#\\server\Users\<username>\Documents\CursorRefres h.ps1#"

if you wanted the file name to be displayed in the field:
"CursorRefresh.ps1#\\server\Users\<username>\Docum ents\CursorRefresh.ps1#"

Either add/update via recordset or update action query methods.


>> This presupposes that there is a field in your table set to be used as a hyperlink field.


非常感谢

我不是代码专家,我是什么意思是用户选择像c:\\\
ote.pdf这样的文件。使用第28行和超链接对话框将打开第31行以从文件中选择文件。文件夹,它将路径更改为Files \\\
ote.pdf (它可用于从每台计算机打开文件,如果我再次移动数据库和文件)

所以我想要更改数据库c:\\\
ote.pdf到Files \\\
ote.pdf作为没有第二个对话框(超链接)的超链接;)

只有一个用户从他/她的计算机中选择文件的对话框 - >文件复制到服务器文件文件夹和超链接到这个文件自动生成;)
Thank you very much
im not pro at codes,what i meant was user select a file like "c:\note.pdf" with line 28 and a hyperlink dialog will open uppon line 31 to select the file from "files" folder and it will change the path to "Files\note.pdf" (it''s availalb to open the file from every computer and if i moved DB and files its possible again)
so i want DB change "c:\note.pdf" to "Files\note.pdf" as a hyperlink without 2nd dialogbox ( hyperlink) ;)
just one dialog box that user picked the file from his/her computer -> file copied to server "files" folder and hyperlink to this file automatically generate ;)


然后我跟着你的问题


首先你需要修改你的代码的错误在我之前的帖子中建议。


其次,要么更改代码以构建网络路径的字符串,又将其用于 filecopy()或者你可以找到一种从网络驱动器中提取信息的方法。 我个人会首先构建字符串。


三,构建你的超链接字符串如上所述


Forth ,使用在步骤3中构建的字符串更新记录的超链接字段。


最后,在用户的表单上进行重新查询,以便新信息显示在表格的窗口。


一旦你修复了当前的错误并编写了基于你如何选择更新超链接字段的基本代码,你可以将其发回(格式化为 [CODE /] )有任何错误等...我们可以帮助您从那里微调脚本。
Then I followed your question

First you need to fix your code''s errors as suggested in my prior post.

Second, either change your code to build the string for the network path and use that for the filecopy() or you can find a way to pull that information from the network drive. I personally would build the string first.

Third, build your hyperlink string as I mentioned above

Forth, update your record''s hyperlink field with the string built in step three.

Finally, do a requery on the user''s form so that the new information is shown in the form''s window.

Once you have your current errors fixed and the basic code written for how you''ve chosen to update the hyperlink field you can post it back (formatted with the [CODE/] ) with any errors etc... and we can help you fine tune the scripting from there.


这篇关于Ms Access浏览文件,复制到DB路径,在DB Path中创建文件的超链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆