Solved

Open Access Form with particular record displayed

Posted on 2014-02-26
2
869 Views
Last Modified: 2014-02-26
I have an Access 2007 form that is opened (by default) on a new record.  The code in the "On Load" event for the form is as follows:

    DoCmd.GoToRecord acDataForm, Me.Name, acNewRec

What I would like to do is open the form, optionally, at a particular record.  I cannot use the "gotorecord" method, because, as I read things, a value specified (instead of the acNewRec  parameter), is an offset.  I want to be able to go to a record based on a primary key value in a table used to populate the form.

Thanks for your help.

Tom
0
Comment
Question by:tpigielski
  • 2
2 Comments
 
LVL 28

Accepted Solution

by:
omgang earned 500 total points
ID: 39889136
Pass a Where expression with the OpenForm command to open the form to the specified record.

DoCmd.OpenForm FormName, , , "PKValue = " & ThePKValue

OM Gang
0
 
LVL 28

Expert Comment

by:omgang
ID: 39889154
See VBA Help for OpenForm Method of DoCmd command.

expression.OpenForm(FormName, View, FilterName, WhereCondition, DataMode, WindowMode, OpenArgs)

OM Gang
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 When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
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…

810 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