complie错误无效或不合格的引用 [英] complie error invalid or unqualified reference

查看:100
本文介绍了complie错误无效或不合格的引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 私有  Sub  Command1_Click()
StartStg = DT_Start.Value
EndStg = DT_end.Value
db_employee.RecordSource = SELECT * FROM employee WHERE (((employee.Date)介于# + StartStg + #和#之间+ EndStg
db_employee.Refresh
rec_count = .recordset.RecordCount
如果 .recordset.RecordCount<> 0 然后
Populate_lvw_recordsfound

cmd_PreviewReport.Enabled = True
其他
cmd_PreviewReport.Enabled = 错误
结束 如果
结束 使用


结束 Sub





错误显示在点击或搜索按钮期间



complie错误

无效或不合格的参考

解决方案

< blockquote>问题在于

 rec_count = .recordset.RecordCount 

.RecordSet ...可能它应该读

 rec_count = db_employee.RecordSet.RecordCount 

你会遇到类似的问题

如果.recordset.RecordCount<> 0然后



还要注意您的代码容易受到 SQL注入攻击 [ ^ ]

您可能还想考虑使用VB.NET - 快递 [ ^ ]版本是free


检查你的哈希计数:

 db_employee.RecordSource =   SELECT * FROM employee WHERE(((employee.Date)介于# + StartStg +  < span class =code-string>#And# + EndStg 

你的意思是

 db_employee .RecordSource =   SELECT * FROM employee WHERE(((employee.Date)介于#& StartStg&  #和#& EndStg *   


Private Sub Command1_Click()
 StartStg = DT_Start.Value
 EndStg = DT_end.Value
    db_employee.RecordSource = "SELECT * FROM employee WHERE (((employee.Date) Between # " + StartStg + " # And # " + EndStg
    db_employee.Refresh
    rec_count = .recordset.RecordCount
    If .recordset.RecordCount <> 0 Then
        Populate_lvw_recordsfound

        cmd_PreviewReport.Enabled = True
    Else
        cmd_PreviewReport.Enabled = False
    End If
End With


End Sub



error showing during click or search button

complie error
invalid or unqualified reference

解决方案

The problem is with the line

rec_count = .recordset.RecordCount

There should be an object reference in front of .RecordSet ... possibly it should read

rec_count = db_employee.RecordSet.RecordCount

You will get a similar problem with

If .recordset.RecordCount <> 0 Then


Also be aware that your code is vulnerable to SQL Injection[^]
You may want to also consider using VB.NET instead - the express[^] version is free


Check your hash count:

db_employee.RecordSource = "SELECT * FROM employee WHERE (((employee.Date) Between # " + StartStg + " # And # " + EndStg

Did you mean

db_employee.RecordSource = "SELECT * FROM employee WHERE (((employee.Date) Between # " & StartStg & " # And # " & EndStg * " #"


这篇关于complie错误无效或不合格的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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