Solved

Open form and position to a record on subform

Posted on 2011-02-21
3
920 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
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…
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…

762 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

23 Experts available now in Live!

Get 1:1 Help Now