Solved

Open form and position to a record on subform

Posted on 2011-02-21
3
927 Views
Last Modified: 2012-05-11
I am using Access 2003 and I would like to open a form containing a subform with the cursor positioned on a specific record in the subform.  The subform contains a column for "ItemNumber" and I would like to specify using VBA code what Item Number in the subform that the cursor will be positioned on.  Is there a way to do this?
0
Comment
Question by:dsoderstrom
  • 2
3 Comments
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 34942851
You need to use the bookmark method. If you know the ItemNumber:

Dim rst As DAO.Recordset
Set rst = Me.NameOfyourSubformCONTROL.Form.Recordset

rst.FindFirst "[ItemNumber]=" & YourItemNumber

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

Obviously you'll have to change the various fields/controls to match your own.


0
 
LVL 84
ID: 34942886
Sorry, forgot to note this:

Be careful with the NameOfYourSubformCONTROL syntax also. This is the name of the Subform control you've placed on your mainform, and may or may not be the same as the Form you're using as a SourceObject. To insure you're working with the correct item, click ONCE on the Subform, then examine the Properties of that item. If you find a property named "SourceObject", you've got the right item. If not, you'll have to de-focuse that item, and try again.
0
 

Author Closing Comment

by:dsoderstrom
ID: 34943775
Worked Perfectly.  Thanks
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
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…

808 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