Solved

How to SetFocus based on a value in a TempVar

Posted on 2011-03-07
3
541 Views
Last Modified: 2012-05-11
Hello. I have a form that displays search results. When the user clicks on a certain record, a macro saves the "ID" value (number) to a TempVar (AccredID_Set).

I then have a macro that opens a new form showing all accreds of the unit the person selected. I would like to SetFocus on the exact record the person selected in the search result form. (So the person doesnt have to go searching through the records again.)

I need to figure out how to set focus based on matching the Accred ID of the new form with the AccredID of the old form. (Saved as a TempVar). I am not finding the syntax or where I should stick the code... (On Load?)

Thanks for the help!

0
Comment
Question by:moot2010
  • 2
3 Comments
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 250 total points
ID: 35058305
Most of the time you use the Bookmark method if you need to move a form to a specific record:

Dim rst As DAO.Recordset
Set rst = Me.RecordsetClone
rst.FindFirst "YourFieldName=" & Tempvars!YourTempvarName

If Not rst.NoMatch Then Me.Bookmark = rst.Bookmark

Note that assume YOurFieldName is a Numeric datatttype. If it's a Text datatype:

rst.FindFirst "YourFieldName='" & Tempvars!YourTempvarName & "'"

0
 

Author Comment

by:moot2010
ID: 35067926
THANKS! I appreciate your help. I know I didn't ask in my original question, but is there a way to select the whole record? Not just the field?
0
 

Author Closing Comment

by:moot2010
ID: 35067930
The example code provided worked perfectly.
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Suggested Solutions

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

839 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