Solved

Open form and position to a record on subform

Posted on 2011-02-21
3
933 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
[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 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 85
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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

617 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