表格有7个组合框 [英] Form with 7 combo boxes

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

问题描述

我有一个包含7个组合框的表单来搜索Access 2007中表格中的各个字段。我正在尝试构建动态表单。或者我的子例程的条件SQL,它只使用来自所选组合框的值来表示where。如果已经做出选择,则标准,否则它将忽略组合框。


例如,如果未选择cmb1,则where子句应如下所示:


从myTable中选择*,其中myField2 =''cmb2'的值'和myField3 =''cmb3'的值'等等


如果另一方面cmb1如果被选中,它将包含在where子句中。


如何创建此条件SQL?还是有更好的方法吗?


谢谢。

解决方案

这是允许你动态的VBA代码createa SQL where子句。

展开 | 选择 | Wrap | 行号


@TheSmileyOne


谢谢为了你的回应。我今晚会试试这个。另外,请提供用于组合Where的代码。用选择
谢谢!


@rhapsodysolutions


看看这个很少searchdemo db我做了一次海报。虽然在早期版本的Access中完成,即不是2007年它在代码背后有你需要的所有成分来给你提供想法

http://bytes.com/topic/access/answer...ed-search-form

I have a form with 7 combo boxes to to search various fields in a table in Access 2007. I am trying to construct "dynamic" or conditional SQL for my subroutine, that would only use the values from selected comboboxes for the "where" criteria if a selection has been made, otherwise it will ignore the combo box.

For example if cmb1 is not selected, the where clause should look like:

select * from myTable where myField2= ''value of cmb2'' and myField3= ''value of cmb3'' and so on

If on the other hand cmb1 is selected, it would be included in the where clause.

How do I create this conditional SQL? or is there a better way to do it?

Thanks.

解决方案

This is VBA code that allows you to dynamically createa SQL where clause.

Expand|Select|Wrap|Line Numbers


@TheSmileyOne
Thanks for your response. I will try this tonight. Also, please provide the code for combining the "Where" with the "select" clause.

Thank you!


@rhapsodysolutions
Take a look at this little searchdemo db I did one time for a poster. Albeit done in an earlier version of Access ie not 2007 It has all the ingredients you need in the code behind to give you ideas

http://bytes.com/topic/access/answer...ed-search-form


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

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