打开表单基于两个组合框选择 [英] Open form based on two combo box selection

查看:53
本文介绍了打开表单基于两个组合框选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要打开一个表格,选择以前表格中的所有数据,即:


表格1)


组合框1命名为 ; cboYearSelect"显示为年基于qry QryYearList(仅一个字段Year)


组合框2命名为cbowwselect显示为wk基于qry Qry WkList(字段:Year,wk)仅显示wk字段。


OPEN FORM(2)BUTTON(@@@)


表格2)我的所有数据:


年份

wk


产品1

产品2等等


(@@@)在此按钮的OnCLick事件过程中我插入了以下代码:

Dim stDocName As String

Dim stLinkCriteria As String


stDocName =" Wkly_data_WIP"


stLinkCriteria =" [Year] =" &安培;我![cboYearSelect]和[wk] =" &安培;我![cbowwselect]

DoCmd.OpenForm stDocName ,,, stLinkCriteria


但是我获得了DataTypeMismatch错误:

哪里是我的错?


非常感谢提前

Bea

解决方案


我需要打开一个表格,选择以前表格中的所有数据,即:


表格1)


组合框1命名为cboYearSelect显示为年基于qry QryYearList(仅一个字段Year)


组合框2命名为cbowwselect显示为wk基于qry Qry WkList(字段:Year,wk)仅显示wk字段。


OPEN FORM(2)BUTTON(@@@)


表格2)我的所有数据:


年份

wk


产品1

产品2等等


(@@@)在此按钮的OnCLick事件过程中我插入了以下代码:

Dim stDocName As String

Dim stLinkCriteria As String


stDocName =" Wkly_data_WIP"


stLinkCriteria =" [Year] =" &安培;我![cboYearSelect]和[wk] =" &安培;我![cbowwselect]

DoCmd.OpenForm stDocName ,,, stLinkCriteria


但是我获得了DataTypeMismatch错误:

哪里是我的错?


非常感谢提前

Bea



试试这个:

stLinkCriteria =" [Year] =" &安培;我![cboYearSelect]& "并且[wk] =" &安培;我![cbowwselect]


如果不起作用,请提供输出结果的样本。



试试这个:

stLinkCriteria =" [Year] =" &安培;我![cboYearSelect]& "并且[wk] =" &安培;我![cbowwselect]


如果它不起作用,请提供输出应该是什么样子的样本。



你好PuppydogBuddy,



我会尝试更好地解释我的问题:

我有一个表格,我选择感兴趣的期间(年和周):

选择了这些vallue我想打开第二个表格,包含所有(已过滤的)

与期间相关的数据(年和周)。


如果我在linkcriteria中分别应用这两个条件,它们没有数据类型不匹配...


谢谢,

Bea


< blockquote>


你好PuppydogBuddy,



我会尝试更好地解释我的问题:

我有一个表格,我选择感兴趣的期间(年和周):

选择这些vallue我想打开所有的第二个形式(过滤)

与期间相关的数据(年份& wk)。


如果我分别在linkcriteria中应用这两个条件,它们的工作没有数据类型不匹配...


谢谢,

Bea



如果年份是数字数据类型而周是文本数据类型,则语法如下所示。需要额外的引号来将参数标识为文本数据类型。


试试这个:

stLinkCriteria =" [Year] =" &安培;我![cboYearSelect]& "并且[wk] =''" &安培;我![cbowwselect]& ""

I need to open a form selecting all data from a previous form i.e:

Form 1)

combo box 1 named "cboYearSelect" displayed as "Year" based on qry QryYearList ( only one field "Year")

combo box 2 named "cbowwselect" displayed as "wk" based on qry Qry WkList (field: Year, wk) displaying only wk field.


OPEN FORM (2) BUTTON (@@@)

Form 2) all my data :

Year
wk

product 1
product 2 and so on

(@@@) in the OnCLick event procedure of this button I inserted the following code:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Wkly_data_WIP"

stLinkCriteria = "[Year]=" & Me![cboYearSelect] And "[wk]=" & Me![cbowwselect]
DoCmd.OpenForm stDocName, , , stLinkCriteria

But I obtain the "DataTypeMismatch" error:
where is my mistake?

Thanks a lot in advance
Bea

解决方案

I need to open a form selecting all data from a previous form i.e:

Form 1)

combo box 1 named "cboYearSelect" displayed as "Year" based on qry QryYearList ( only one field "Year")

combo box 2 named "cbowwselect" displayed as "wk" based on qry Qry WkList (field: Year, wk) displaying only wk field.


OPEN FORM (2) BUTTON (@@@)

Form 2) all my data :

Year
wk

product 1
product 2 and so on

(@@@) in the OnCLick event procedure of this button I inserted the following code:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Wkly_data_WIP"

stLinkCriteria = "[Year]=" & Me![cboYearSelect] And "[wk]=" & Me![cbowwselect]
DoCmd.OpenForm stDocName, , , stLinkCriteria

But I obtain the "DataTypeMismatch" error:
where is my mistake?

Thanks a lot in advance
Bea

Try this:
stLinkCriteria = "[Year]= " & Me![cboYearSelect] & " And [wk]= " & Me![cbowwselect]

If it does not work, please provide sample of what the output is supposed to look like.


Try this:
stLinkCriteria = "[Year]= " & Me![cboYearSelect] & " And [wk]= " & Me![cbowwselect]

If it does not work, please provide sample of what the output is supposed to look like.

Hello PuppydogBuddy,

thansk for your reply, but the error persist also with your suggested modification.

I''ll try to explain my problem better:
I have a form where I choose the interested period (Year & Wk):
selected these vallue I want to open a second form with all (filtered)
data related to the period (Year & wk).

If I apply the two condition in the linkcriteria separately they work without data type mismatch...

Thanks,
Bea


Hello PuppydogBuddy,

thansk for your reply, but the error persist also with your suggested modification.

I''ll try to explain my problem better:
I have a form where I choose the interested period (Year & Wk):
selected these vallue I want to open a second form with all (filtered)
data related to the period (Year & wk).

If I apply the two condition in the linkcriteria separately they work without data type mismatch...

Thanks,
Bea

if year is numeric data type and week is text data type, the syntax would look like as shown below. Additional quotes needed to identify the parameter as a text data type.

Try this:
stLinkCriteria = "[Year]= " & Me![cboYearSelect] & " And [wk]= ''" & Me![cbowwselect] & "''"


这篇关于打开表单基于两个组合框选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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