Click here to Skip to main content
15,896,201 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
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
Posted
Updated 10-Jun-15 21:22pm
v2
Comments
Richard MacCutchan 11-Jun-15 3:48am    
You need to provide the qualifier for .recordset, the compiler cannot guess what it is part of. I notice you have an End With statement there, but where is its beginning?

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
 
Share this answer
 
Comments
Member 11757843 11-Jun-15 3:45am    
If .recordset.RecordCount <> 0 Then

complie error
invalid or unqualified reference
CHill60 11-Jun-15 5:01am    
I told you that you would get that error and it is exactly the same fix as the previous line. See also the comment from Richard MacCutchan - you have an End With but no starting With db_employee (or whatever was in there that was lost when you copied the code)
Member 11757843 11-Jun-15 3:55am    
please reply
Check your hash count:
VB
db_employee.RecordSource = "SELECT * FROM employee WHERE (((employee.Date) Between # " + StartStg + " # And # " + EndStg
Did you mean
VB
db_employee.RecordSource = "SELECT * FROM employee WHERE (((employee.Date) Between # " & StartStg & " # And # " & EndStg * " #"
 
Share this answer
 
Comments
Member 11757843 11-Jun-15 3:43am    
error showing again
on
rec_count = .recordset.RecordCount

error coming on recordset

complie error
invalid or unqualified reference
OriginalGriff 11-Jun-15 3:56am    
Let me guess...you copied this code from somewhere?
Go back there and look more closely. Was this code inside a With block? If so, you either need to copy the With as well, or add the variable the With referred to to all relevant lines...
Member 11757843 11-Jun-15 4:02am    
db_employee.Refresh

syntex error-in from clause
runtime error- 2147217900(80040e14)
method 'refresh' of obkect 'IAdodc' failed
Member 11757843 11-Jun-15 5:30am    
Private Sub Command1_Click()
StartStg = DT_Start.Value
EndStg = DT_end.Value
lvw_recordsfound.ListItems.Clear

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

rec_count = db_employee.recordset.RecordCount
If db_employee.recordset.RecordCount <> 0 Then
Populate_lvw_recordsfound

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

error in line : rec_count = db_employee.recordset.RecordCount

run time error 91
objectt variable or with block variable not set

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900