Filter Recordset (1 Viewer)

ria4life

Registered User.
Local time
Yesterday, 20:25
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:

jdraw

Super Moderator
Staff member
Local time
Yesterday, 23:25
Joined
Jan 23, 2006
Messages
15,379
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.
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 20:25
Joined
Aug 30, 2003
Messages
36,125
And I moved the thread out of the code repository. ;)
 

Cronk

Registered User.
Local time
Today, 13:25
Joined
Jul 4, 2013
Messages
2,772
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

Top Bottom