Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 936
  • Last Modified:

Open Access Form with particular record displayed

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
tpigielski
Asked:
tpigielski
  • 2
1 Solution
 
omgangCommented:
Pass a Where expression with the OpenForm command to open the form to the specified record.

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

OM Gang
0
 
omgangCommented:
See VBA Help for OpenForm Method of DoCmd command.

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

OM Gang
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now