Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to SetFocus based on a value in a TempVar

Posted on 2011-03-07
3
Medium Priority
?
572 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 1000 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

610 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