How to loop through records and select matching record in access form vba?

Posted on 2012-08-24
Last Modified: 2012-08-24
I just need to be able to loop through the records of a query and if they meet the criteria then select the record on the form and unhide the form.

Here is what I'm thinking the code may look like based on some googling;

Private Sub Form_Timer()


<<Loop code here ....if fOSUserName() = Me.UserName Then (need to incorporate this criteria)>>

Me.Form.Visible = True

End If

End Sub

I have looked up loops through google but really am not sure exactly how to set it up.. The forms datasource is the source that needs be looped through.. [qryNotifications]

Thanks a ton for the help!
Question by:SeyerIT
    LVL 119

    Accepted Solution

    try something like this

    Private Sub Form_Timer()

    with me.recordset
        do until .eof
             if ... then
                   Me.Form.Visible = True
             end if

    end with

    End Sub
    LVL 2

    Author Comment

    Does the trick perfectly! Thanks!

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Suggested Solutions

    It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
    Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
    Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now