基于查询的表单 [英] form based on a query

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

问题描述

你好


我有一个基于查询的表格


它是由一个命令按钮打开的 - 当单击命令按钮时,tect框提示标准输入单词


查询在课程列表中搜索包含单词的任何内容。然后表单打开并显示那些记录


到目前为止一直很好 - 但是如果单词没有匹配,则需要
- 表单打开,但只是一个灰色的屏幕 - 没有框或任何东西 - 只是空白


我已经尝试了命令按钮和表单本身的代码 - 我会就像一个消息框说没有要显示的记录然后关闭表单和上一个屏幕(上面有命令按钮)重新出现


我甚至尝试在查询的SQL上添加一些额外的代码 - 但绝对没有运气


如果有一个包含以下代码的记录,我可以显示一个消息框:

Private Sub Form_Load()

如果[课程名称]<> ""然后

MsgBox"是记录


结束如果

结束子


和我试过

Else

MsgBox没有记录

但是那不起作用

错误时的
a消息框表单加载确实出现了 - 但它会查询是否返回了某些内容


难倒 - 任何帮助都很有意义

谢谢

Shona

Hello

I''ve got a form which is based on a query

It''s opened by a command button - when the command button is clicked a tect box prompts for the criteria "enter word"

The query searches a list of courses for any containing the "word" and then the form opens and displays those records

So far so good - BUT
if there are no matches for the "word" - the form opens but is just a grey screen - no boxes or anything - just blank

I''ve tried code on the command button and on the form itself - I''d just like a message box saying "no records to display" and then for the form to close and the previous screen (with the command button on it) to reappear

I''ve even tried putting some extra code on the SQL of the query - but having absolutely no luck

I can get a message box to display if there is a record with the following code:
Private Sub Form_Load()
If [course name] <> "" Then
MsgBox "is record"

End If
End Sub

and I tried
Else
MsgBox "no record"
but that didn''t work

a message box on the "on error" of the form load does come up - but it comes up whether the query returns something or not

stumped - any help greatfully received
thanks
Shona

推荐答案

我遇到了这个问题,你能做的是
I had this problem, what you can do is
展开 | 选择 | Wrap | 行号


对不起,如果你使用SELECT COUNT(*)FROM query;,我可以说一件事。然后记录计数将始终为1,因为你有一个结果 - 它的值为0,但它是一个结果。如果使用count函数,则可以使用result(0)而不是results.recordcount,因为result(0)将使用SELECT COUNT(*)FROM query;返回的值;
Sorry, one thing I for to say, if you use "SELECT COUNT(*) FROM query;" then recordcount will ALWAYS be 1 as you have a result - its a value of 0, but it''s a result. If you use the count function, you can use result(0) instead of results.recordcount as results(0) will use the value returned by "SELECT COUNT(*) FROM query;"


非常感谢 - 我试了一下但是得到了

运行时错误3061

参数太少了。预计1

就行了:

设置结果= dbs.OpenRecordset(" SELECT * FROM selcour;")


不确定这是什么意思

Shona
thanks very much - I gave it a try but get
runtime error 3061
too few parameters. Expected 1
on the line:
Set results = dbs.OpenRecordset("SELECT * FROM selcour;")

not sure what it means
Shona


这篇关于基于查询的表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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