如何使用参数从MS Access打开URL [英] How to open a URL from MS Access with parameters

查看:279
本文介绍了如何使用参数从MS Access打开URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基本的MS Access应用程序,该应用程序在表单上具有一个按钮,该按钮应打开一个以Access记录的ID作为参数的网页,但是我尝试执行的所有操作都会导致Access错误或仅导致基本URL错误在网页中打开.

I have a basic MS Access application that has a button on a form that should open a webpage with the ID of the Access record as the parameter, but everything I have tried results either in an error by Access or only the base URL opening in the web page.

我曾尝试将VBA添加到按钮的click事件中,

I have tried adding VBA to the button's click event as so:

Application.FollowHyperlink _ 
"http://example.com/index.php?r=controller/action&id=" & Me.ID 

但我得到的只是在网络浏览器中打开的基本URL(即 http://example.com ).如果我删除?"和&"从完整网址开始,该按钮将打开完整网址减去?"的浏览器.和&",这当然会使页面出错.

but all I get is the base URL opening on the web browser (ie http://example.com). If I remove the '?' and the '&' from the full URL the button will open the browser with the full URL minus the '?' and the '&', which of course errors the page.

我尝试将超链接控件的属性设置为:

I have tried setting a hyperlink control's property as:

="http://example.com/index.php?r=controller/action&id=" & Me.ID

但它执行与上述相同的操作.

but it does the same thing as noted above.

我尝试创建具有相同结果的宏.我尝试使用Hyperlink Builder并使用[formName]![id]作为参数,但是发生相同的事情或访问错误.

I have tried creating a Macro with the same results. I have tried using the Hyperlink Builder and using [formName]![id] as the parameter but same thing happens or Access errors.

我已阅读本文: https://msdn.microsoft. com/en-us/library/office/ff822080.aspx ,并尝试将'index.php/之后的URl中的部分添加到代码中的ExtraInfo位置,但是还是一样.

I have read this article: https://msdn.microsoft.com/en-us/library/office/ff822080.aspx and tried adding the part in the URl after 'index.php/ to the ExtraInfo place in the code, but same thing.

帮助!只需简单地使Access打开一个在URL末尾带有参数的URL并不难.

Help! It can't be that hard to simply have Access open a URL with a parameter on the end of the URL.

推荐答案

Application.FollowHyperlink善变.

使用ShellExecute:
在具有VBA的默认浏览器中打开html页面?

CreateObject("Shell.Application").Open "http://example.com/index.php?r=controller/action&id=" & Me.ID 

请参见 https://stackoverflow.com/a/18922262/3820271

这篇关于如何使用参数从MS Access打开URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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