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
Solved

Bookmark causing error with acFormAdd

Posted on 2014-02-04
4
346 Views
Last Modified: 2014-02-04
Dear experts -
I open a form with the acFormAdd parameter. I DO want to enter this form in the 'enter record mode'.
That form also has a 'Search'  button, which invokes a popup form, from which one can select an existing record (same table).
Once a record is selected in the popup, it sets the bookmark in the calling form and closes the popup.
HOWEVER, this is generating a NO CURRENT RECORD error.
Any way around this?
Thanks -
0
Comment
Question by:terpsichore
4 Comments
 
LVL 4

Assisted Solution

by:Jack Leach
Jack Leach earned 200 total points
ID: 39832197
If the form is opened in DataEntry mode, it doesn't have access to any previous records, thus you can't search for any records.

Perhaps you'd like to move to a new record when the form is opened, instead of opening it in Data Entry mode?

Private Sub Form_Open(Cancel As Integer)
    DoCmd.GotoRecord , , acNewRec
End Sub

Open in new window


hth
0
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 300 total points
ID: 39832202
acFormAdd basically puts you into Data Entry Mode, so you can't edit records, therefore your bookmark would not be recognized as a valid record.

If you need to Enter AND Edit records in that form, you must open it in "normal" view. You can then take the user to a New record if needed like this:

DoCmd.RunCommand acCmdRecordsGoToNew

You might be able to use the OpenArgs method of the OpenForm method to instruct your form to move to a new record. For example:

DoCmd.OpenForm "YourForm", acNormal, , , , , "NewRecord"

Then in the form's Open or Load event:

If Nz(Me.OpenArgs, "") = "NewRecord" Then
  DoCmd.RunCommand acCmdRecordsGoToNew
End If
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39832276
you just need to revise the codes, wrap the codes that bookmark the record with

if me.newrecord=false then

  '  codes  to bookmark a record

end if
0
 

Author Closing Comment

by:terpsichore
ID: 39832332
perfect - many thanks.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

839 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