如何添加功能的组合框<全部选择>在Microsoft Access窗体 [英] How to add functionality for ComboBox <Select All> in Microsoft Access forms

查看:270
本文介绍了如何添加功能的组合框<全部选择>在Microsoft Access窗体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我发布了一个问题,前些天关于需要有一个全选选项添加到2 ComoBoxes的访问形式。我可以用一个工会的选项添加到他们的2。然而,选择什么也不做的呢。我发现,从ComboBox采取的形式参数的查询,这是我需要添加的选项全选,除了盯着它几个小时后,我又没有得到线索。

So I posted a question the other day about an access form that needed to have a "Select All" option added to the 2 ComoBoxes. I was able to add in the option to the 2 of them using a union. However, the options do nothing as of yet. I found the Query that takes the form parameters from the ComboBox and this is where I need to add in the option to select all, except after staring at it for hours I've got no clue again.

数据库不是我写的,这是约10岁,并给了我增加一些新的功能。我已经做到了,并且车主抱怨说,全选按钮,从来没有工作过。经考证,该按钮具有的VB脚本清除组合框输入无效值。我打算现在再杀这些,因为我已经添加了一些选项的组合框本身。

The Database wasn't written by me, it's approximately 10 years old and was was given to me to add some new features. I have done that, and the owner complained that the "Select All" buttons have never worked. After research, the buttons have VB script that clears the ComboBox input to nullified value. I am planning on scrapping those now since I have added the option to the ComboBox itself.

这是康宝读取输入的SQL查询看起来是这样的:

The SQL query that reads combo input looks like this:

PARAMETERS [Forms]![ReportCentre]![cboTreatmentType] Short, [Forms]![ReportCentre]!      [cboTreatmentDate] Short;


SELECT addresses.*,
       [firstname] & "" & [lastname]
       AS Name,
       [street] & "," & [suburb] & "" & [stateorprovince] & "" & [postalcode]
       AS
       Address
FROM   addresses
WHERE  ( ( ( addresses.treatmentid ) = [forms] ! [reportcentre] !
                                                [cbotreatmenttype].[Value] )
         AND ( ( addresses.treatmentdate ) = [forms] ! [reportcentre] !
                                                 [cbotreatmentdate].[Value] )
         AND ( ( addresses.birthmonth ) LIKE [forms] ! [reportcentre] !
                                             [txtbirthmonth].[Value]
                                                 & "*" ) )
        OR ( ( ( addresses.treatmentid ) IS NULL )
             AND
       ( ( addresses.treatmentdate ) = [forms] ! [reportcentre] !
                                           [cbotreatmentdate].[Value] )
             AND ( ( addresses.birthmonth ) LIKE [forms] ! [reportcentre] !
                                                 [txtbirthmonth].[Value]
                                                     & "*" ) )
        OR ( ( ( addresses.treatmentid ) = [forms] ! [reportcentre] !
                                                 [cbotreatmenttype].[Value] )
             AND ( ( addresses.treatmentdate ) IS NULL )
             AND ( ( addresses.birthmonth ) LIKE [forms] ! [reportcentre] !
                                                 [txtbirthmonth].[Value]
                                                     & "*" ) )
        OR ( ( ( addresses.treatmentid ) IS NULL )
             AND ( ( addresses.treatmentdate ) IS NULL )
             AND ( ( addresses.birthmonth ) LIKE [forms] ! [reportcentre] !
                                                 [txtbirthmonth].[Value]
                                                     & "*" ) )
        OR ( ( ( addresses.treatmentid ) IS NULL )
             AND
       ( ( addresses.treatmentdate ) = [forms] ! [reportcentre] !
                                           [cbotreatmentdate].[Value] )
             AND ( ( addresses.birthmonth ) IS NULL ) )
        OR ( ( ( addresses.treatmentid ) = [forms] ! [reportcentre] !
                                                 [cbotreatmenttype].[Value] )
             AND ( ( addresses.treatmentdate ) IS NULL )
             AND ( ( addresses.birthmonth ) IS NULL ) )
        OR ( ( ( addresses.treatmentid ) = [forms] ! [reportcentre] !
                                                 [cbotreatmenttype].[Value] )
             AND
       ( ( addresses.treatmentdate ) = [forms] ! [reportcentre] !
                                           [cbotreatmentdate].[Value] )
             AND ( ( addresses.birthmonth ) IS NULL ) ); 

我知道这很凌乱,很难理解,这就是为什么即时通讯寻求帮助。我如何获取验证了全选选项,这两个组合框?

I know it's messy and hard to understand, which is why im asking for help. How do I get that to validate a "Select All" option for both ComboBoxes?

推荐答案

一个非常简单的方法是设置组合的约束列*:

One very easy way is to set the bound column of the combo to *:

 SELECT "*" As ID, "Select All" As AText 
 FROM Table1 
 UNION SELECT Table1.ID, Table1.AText 
 FROM Table1;

使用您的组合:

 Select "*" As TreatmentID, "<<All Records>>" As Treatment 
 FROM Treatment 
 UNION 
 Select Treatment.TreatmentID, Treatment.Treatment 
 From Treatment;

您可以再使用,如:

SELECT Table1.ID
FROM Table1
WHERE Table1.ID Like [forms]![MainForm]![Combo]

使用您的SQL:

... WHERE (((Addresses.TreatmentID) 
  Like [Forms]![ReportCentre]![cboTreatmentType]) AND ...

如果你只有一列,你可以使用:

If you only have a single column, you can use:

SELECT Table1.Atext
FROM Table1
WHERE AText Like 
   IIf(Forms![MainForm]!Combo="Select All","*",Forms![MainForm]!Combo)

这篇关于如何添加功能的组合框&LT;全部选择&GT;在Microsoft Access窗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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