Solved

How to SetFocus based on a value in a TempVar

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

747 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

9 Experts available now in Live!

Get 1:1 Help Now