Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2012-08-24
2
Medium Priority
?
979 Views
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()

Me.Requery

<<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!
0
Comment
Question by:SeyerIT
2 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 38330184
try something like this

Private Sub Form_Timer()

Me.Requery
with me.recordset
    .movefirst
    do until .eof
         if ... then
               Me.Form.Visible = True
         end if
        .movenext
    loop

end with

End Sub
0
 
LVL 2

Author Comment

by:SeyerIT
ID: 38330309
Does the trick perfectly! Thanks!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
A Case Study of using the Windows API to provide RS232 communications capability in Access without the use of Active-X controls.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

572 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