错误提示“没有为命令对象设置命令”什么意思?

langlaila 2003-09-22 10:59:50
我在类模块中有一窗体,showForm起调用form,代码如下,但运行后提示“没有为命令对象设置命令”,但以下语句在另外的类模块中运行时没有问题的
Public Function showForm(i As Integer)
Dim rs As Recordset
Dim strSQL As String

Dim intRow As Integer
Dim intCol As Integer


Select Case i
Case 1
strSQL = "select * from Country"
Case 2
strSQL = "select * from Area"
Case 3
strSQL = "select * from Agent"
Case 4
strSQL = "select * from customer"
End Select
Set rs = Cn.Execute(strSQL)
End Function
...全文
374 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
redsoft 2003-09-22
  • 打赏
  • 举报
回复
你无法通过该函数得到任何结果,如果想获得记录集,可以修改如下:
Public Function showForm(i As Integer) As ADODB.RecordSet
Dim rs As Recordset
Dim strSQL As String

Dim intRow As Integer
Dim intCol As Integer


Select Case i
Case 1
strSQL = "select * from Country"
Case 2
strSQL = "select * from Area"
Case 3
strSQL = "select * from Agent"
Case 4
strSQL = "select * from customer"
End Select
Set rs = Cn.Execute(strSQL)
set showForm=rs
End Function
strongfisher 2003-09-22
  • 打赏
  • 举报
回复
up
langlaila 2003-09-22
  • 打赏
  • 举报
回复
我知道啦,参数i没成功传递
yoki 2003-09-22
  • 打赏
  • 举报
回复
你这个不是函数啦~,没有返回值
你想返回纪录集的话,按照楼上的修改吧
若只是为全局变量赋值,那就用过程
yoki 2003-09-22
  • 打赏
  • 举报
回复
你这个不是函数啦~,没有返回值
你想返回纪录集的话,按照楼上的修改吧
若只是为全局变量赋值,那就用过程

1,216

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧