将fieldname传递给子例程 [英] Passing fieldname to a subroutine

查看:69
本文介绍了将fieldname传递给子例程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含子表单的表单。在子表单中,我有几个字段

,我正在为文件服务器上的文档分配链接。我学会了

(从这个列表:-)如何添加链接。因为我将执行

四个或五个字段的代码,我希望有一个通用的

子例程来传递字段名称参数。我已经搜索了并且

为此尝试了很多格式和语法但没有成功。


以下是我希望做的更多的例行程序的原则行

一般


lnkApplication = varFile& "#" &安培; varFile''将超链接放在

字段中。


lnkApplication.Visible = Not(IsNull(lnkApplication.Value))''仅

显示表单上的字段,如果它有一个路径


lnkApplication是一个名为

tblFamilyMembers的表中字段的实际名称。


请帮助我使用语法将字段名传递给一般的

子程序并修改上面的行。另外,请告诉我

是否需要额外的代码才能使其工作。


谢谢,

伯尼

I have a form with a subform. In the subform I have several fields to
which I am assigning links to documents on the file server. I learned
(from this list :-) how to add the links. Because I will be executing
the code for four or five fields, I would like to have a generic
subroutine to pass the field name parameters to. I have searched and
tried many formats and syntaxes for this with no success.

Here are the principle lines from the routine that I wish to make more
general

lnkApplication = varFile & "#" & varFile '' puts the hyperlink in the
field.

lnkApplication.Visible = Not (IsNull(lnkApplication.Value)) '' only
shows the field on the form if it has a path in it

lnkApplication is the actual name of the field in a table called
tblFamilyMembers.

Please help me with the syntax to pass the fieldnames to a general
subroutine and to modify the lines above. Also, please let me know if
there are any additional lines of code needed to make it work.

Thanks,
Bernie

推荐答案

我不知道你的例子是什么,但传递信息的方式

进入子程序非常简单...

Sub MySubroutine(byval strFieldName as string)

dim strSQL as string

strSQL =" SELECT * FROM MyTable WHERE [" &安培; strFieldName& "] =

''X'';"

DBEngine(0)(0).Querydefs(" qdfTemp")。SQL = strSQL

End Sub


这有帮助吗?

haven''t a clue what your example is on about, but the way to pass info
into a subroutine is pretty simple...

Sub MySubroutine(byval strFieldName as string)
dim strSQL as string
strSQL = "SELECT * FROM MyTable WHERE [" & strFieldName & "] =
''X'';"
DBEngine(0)(0).Querydefs("qdfTemp").SQL = strSQL
End Sub

Does that help?


我猜是lnkApplication是还可以控制你的表格,如果是这样的话

你可以通过对控件的引用


例如


Sub wibble(MyControl as Ontrol)

''东西你已经有了


使用MyControl

.Value = varFile &安培; "#" &安培; varFile

.Visible = Not(IsNull(.Value))

结束

结束子

你和你用它来称呼它是
来电晃动(Me.lnkApplication)


-


Terry Kreft

< bg ******** @ gmail.com写信息

新闻:11 *********** **********@m73g2000cwd.googlegro ups.com ...
I''m guessing that lnkApplication is also the control on your form, if so
you can pass a reference to the control

e.g.

Sub wibble(MyControl as Ontrol)
'' Stuff you''ve already got

With MyControl
.Value = varFile & "#" & varFile
.Visible = Not (IsNull(.Value))
End With
End Sub
And you''d call it with
Call wibble(Me.lnkApplication)


--

Terry Kreft
<bg********@gmail.comwrote in message
news:11*********************@m73g2000cwd.googlegro ups.com...

我有一个包含子表单的表单。在子表单中,我有几个字段

,我正在为文件服务器上的文档分配链接。我学会了

(从这个列表:-)如何添加链接。因为我将执行

四个或五个字段的代码,我希望有一个通用的

子例程来传递字段名称参数。我已经搜索了并且

为此尝试了很多格式和语法但没有成功。


以下是我希望做的更多的例行程序的原则行

一般


lnkApplication = varFile& "#" &安培; varFile''将超链接放在

字段中。


lnkApplication.Visible = Not(IsNull(lnkApplication.Value))''仅

显示表单上的字段,如果它有一个路径


lnkApplication是一个名为

tblFamilyMembers的表中字段的实际名称。


请帮助我使用语法将字段名传递给一般的

子程序并修改上面的行。另外,请告诉我

是否需要额外的代码才能使其工作。


谢谢,

伯尼
I have a form with a subform. In the subform I have several fields to
which I am assigning links to documents on the file server. I learned
(from this list :-) how to add the links. Because I will be executing
the code for four or five fields, I would like to have a generic
subroutine to pass the field name parameters to. I have searched and
tried many formats and syntaxes for this with no success.

Here are the principle lines from the routine that I wish to make more
general

lnkApplication = varFile & "#" & varFile '' puts the hyperlink in the
field.

lnkApplication.Visible = Not (IsNull(lnkApplication.Value)) '' only
shows the field on the form if it has a path in it

lnkApplication is the actual name of the field in a table called
tblFamilyMembers.

Please help me with the syntax to pass the fieldnames to a general
subroutine and to modify the lines above. Also, please let me know if
there are any additional lines of code needed to make it work.

Thanks,
Bernie



" Terry Kreft" < te ********* @ mps.co.ukwrote

新闻:Ky ******************** @ karoo.co.uk:
"Terry Kreft" <te*********@mps.co.ukwrote in
news:Ky********************@karoo.co.uk:

Sub wibble(MyControl as Ontrol)

''东西你已经有了


使用MyControl

.Value = varFile& "#" &安培; varFile

.Visible = Not(IsNull(.Value))

结束

结束Sub
Sub wibble(MyControl as Ontrol)
'' Stuff you''ve already got

With MyControl
.Value = varFile & "#" & varFile
.Visible = Not (IsNull(.Value))
End With
End Sub



函数声明应为:


Sub wibble(MyControl as Control)


-

David W. Fenton http://www.dfenton.com/

usenet at dfenton dot com http://www.dfenton.com/ DFA /


这篇关于将fieldname传递给子例程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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