Solved

Bookmark causing error with acFormAdd

Posted on 2014-02-04
4
350 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
[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
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

740 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