Solved

How to SetFocus based on a value in a TempVar

Posted on 2011-03-07
3
532 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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…

785 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