本文介绍了如何设置选项框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在尝试在表单中设置一个选项框来提供参数查询

用作过滤器。我要过滤的字段是文本字段,

有两个可能的值:A和A。和B。所以我的Option Box应该有三个

选项:A ; " B" :和A;或B或B。 (任何)。非常基本的东西。

我无法让它工作,对于州议员来说,似乎只允许数字作为选项框的数据类型
,如果我尝试使用组合框

(我愿意使用任何能够完成工作的东西),不能得到A。或者

" B"工作。

我相信这对我这里的每个人都很容易。我被困在这里,

请帮忙。

Hi,
I''m trying to set up an Option Box in a form to feed a Parameter Query
to be used as a filter. That field I want to filter is a Text field and
has two posible values: "A" and "B". So my Option Box should have three
options: "A" ; "B" : and "A" Or "B" (any). Pretty basic stuff.
I can''t get it to work, for staters it seems that only numbers are
allowed as data types for option boxes, and if I try to use a combo box
(I''m willing to use anything that does the job), can''t get the "A" Or
"B" to work.
I''m sure this is easy stuff for everyone here but me. I''m stuck here,
please help.

推荐答案



使用带数字的选项框。我假设表单上有一个

按钮来执行查询。将一些代码放在该按钮的

点击事件中,以创建正确的过滤。如果

您的查询被用作表单或报表的记录源,

将参数从查询中取出并传递给

docmd.openform(openreport)


如果你直接打开查询,(顽皮)那么你将需要一些额外的代码才能得到查询。在打开之前

吧。


private sub btnOpenReport

dim stWhereClause as string

select case me .optionAB

案例1

stWhereClause =" [myfield] =''A''"

案例2

stWhereClause =" [myfield] =''B''"

case else

''如果[myfield]只能是A或B.

stWhereClause =" [myfield] =''A''或[myfield] =''B''"

end select

Docmd.openform" myform" ,,, stWhereClause


在使用之前检查我的代码中的拼写错误。

我有一个过滤器rm有25个选项可以放入报告的

where子句。


-

Bob Quintal


PA是我改变了我的电子邮件地址。


use the option box with numbers. I''ll assume that there is a
button on the form to execute the query. Put some code in the on
click event of that button which creates the right filtering. If
your query is used as the recordsource for a form or report,
take the parameter out of the query and pass it in the
docmd.openform (openreport)

If you are opening the query directly, (naughty) then you''ll
need some additional code to mody hte querydef before opening
it.

private sub btnOpenReport
dim stWhereClause as string
select case me.optionAB
case 1
stWhereClause = "[myfield] = ''A''"
case 2
stWhereClause = "[myfield] = ''B''"
case else
''maybe just leave this blank if [myfield] can only be A or B.
stWhereClause = "[myfield] = ''A'' OR [myfield] = ''B''"
end select
Docmd.openform "myform",,,stWhereClause

Check for typos in my code before using.
I have a filter form that has 25 options that get put into the
where clause for a report.

--
Bob Quintal

PA is y I''ve altered my email address.




在框架的AfterUpdate事件中,您可以输入类似

Dim strFilter As String

选择Case Me.Frame1

strFilter =" [FieldToFilter] =''A''"

选择Case Me.Frame1

strFilter =" [FieldToFilter] =''B''"

选择Case Me.Frame1

strFilter =" [FieldToFilter] =''A''或 &安培; _

" [FieldToFilter] =''B''

结束选择

Me.Filter = strFilter

Me.FilterOn = True


您可以突出显示任何单词并按F1键,在代码

模块中,以获得进一步的帮助/说明。


In the AfterUpdate event of the frame you could enter something like
Dim strFilter As String
Select Case Me.Frame1
strFilter = "[FieldToFilter] = ''A''"
Select Case Me.Frame1
strFilter = "[FieldToFilter] = ''B''"
Select Case Me.Frame1
strFilter = "[FieldToFilter] = ''A'' Or " & _
"[FieldToFilter] = ''B''
End Select
Me.Filter = strFilter
Me.FilterOn = True

You can highlight any of the words and press the F1 key, while in a code
module, to get further help/description.




这篇关于如何设置选项框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 02:55