检索VBA中的记录计数 [英] Retrieve a record count in VBA

查看:124
本文介绍了检索VBA中的记录计数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Access中编写数据库,我需要VB代码语法方面的帮助。我需要做的是在第一个字段中选择一个名称后,它会触发一个运行以下代码的事件过程:

I''m writing a database in Access and I need help with syntax for VB code. What i need it to do is after a name is chosen in the first field it triggers an event procedure that runs the following code:

展开 | 选择 | Wrap | 行号

推荐答案

我还没读过第二行,因为它显然是错的。 iCount 必须是整数,但您要为其指定一个字符串。字符串似乎包含SQL语句的事实完全无关。
I haven''t read past the second line yet, because it''s obviously wrong. iCount must be an Integer, but you are assigning a string to it. The fact that the string appears to contain an SQL statement is entirely irrelevant.


我知道它是错的,我遇到的问题是如何设置特定的SQL语句生成整数而不是字符串?


还有一种方法我可以将一个SQL命令写入if语句而不是先将它分配给变量吗?我尝试了多种方法,但每次都会出现语法错误。
I know it''s wrong, the problem I''m having is how do i set that particular SQL statment to produce an integer instead of a string?

Also is there a way i could just write a SQL command into the if statement instead of assigning it to a variable first? I tried multiple ways of doing it but i keep getting syntax error each time.



我知道这是错的,问题我'我有如何设置特定的SQL语句来生成整数而不是字符串?
I know it''s wrong, the problem I''m having is how do i set that particular SQL statment to produce an integer instead of a string?



您需要对数据库实际执行命令。就在此刻,我不记得如何在VBA内这样做。我将把这个讨论主题移到Access论坛,你无疑会在那里找到更好的回复。

You need to actually execute a command against the database. Just at the moment, I don''t recall how to do so from within VBA. I''m going to move this discussion thread over to the Access forum, where you''ll undoubtedly find a much better response.


也是有一种方法我可以将一个SQL命令写入if语句而不是先将它分配给变量?我尝试了多种方法,但每次都会出现语法错误。
Also is there a way i could just write a SQL command into the if statement instead of assigning it to a variable first? I tried multiple ways of doing it but i keep getting syntax error each time.



副手,我能想到的唯一方法就是创建一个函数做数据库命令并返回记录计数,并在你的函数中使用该函数如果测试。


哦,我也要改变主题的标题。 VB帮助太模糊了,没有人会知道它是什么。

Off-hand, the only way I can think of would be to create a function do do the database command and return the record count, and use that function in your IF test.

Oh, and I''m going to change the title of the thread, too. "VB Help" is much too vague, nobody will know what it''s about.


这篇关于检索VBA中的记录计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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