Filter Recordset

ria4life

Registered User.
Local time
Yesterday, 19:06
Joined
Feb 24, 2016
Messages
40
Someone please assist..Cant get this to work right....I keep getting the first value in the query and not the filtered value.



Code:
Dim rs As Recordset
    
Set rs = CurrentDb.OpenRecordset("Qry_Availability", dbOpenSnapshot, dbReadOnly)
    
rs.Filter = "[date_selected] = '" & Me.Sig1 & "'"
Me.I1 = rs.Fields("Occurance").Value
    
       
If rs.NoMatch Then
        Me.I1.BackColor = vbGreen
        Exit Sub
        Else: Me.I1.BackColor = vbRed
        End If
 
Last edited by a moderator:
I approved your post after adding the code tags. You should always use code tags when posing code. And you should post all the code in a procedure --what is posted is not the complete routine.
I recommend you identify the recordset as
Code:
Dim rs as DAO.Recordset
It also helps if you tell readers what you are trying to do in simple, plain English.
 
And I moved the thread out of the code repository. ;)
 
Is [date_selected] a date? If so, # should be used instead of '

Rather than the filter, use
Set rs = CurrentDb.OpenRecordset("select * from Qry_Availability where [your filter]")
if rs.recordcount < 1 then
......
 

Users who are viewing this thread

Back
Top Bottom