Solved

Create New Record using Command button on Separate form

Posted on 2008-10-28
16
4,673 Views
Last Modified: 2013-11-28
Problem:  Unable to create new record.
Description:   On "frmMain", I have "cmdAddNew" button (Caption : + Person).  "cmdAddNew" should open up "frmProfile" and create a new record for editing.  However, I keep getting the "You can't go to specified record" error.  
IMED-Test.zip
0
Comment
Question by:njmatt
  • 9
  • 7
16 Comments
 
LVL 75
ID: 22825331
Can  you post the code for the command button?

mx
0
 
LVL 1

Author Comment

by:njmatt
ID: 22825344
I posted the DB as well if you need to take a look.  
Private Sub cmdAddNew_Click()
     DoCmd.OpenForm "frmProfile"
     DoCmd.GoToRecord , , acNewRec
     
End Sub

Open in new window

0
 
LVL 75
ID: 22825404
Quick fix:

Private Sub cmdAddNew_Click()
     DoCmd.OpenForm "frmProfile"
     On Error Resume Next                                '*** add this
     DoCmd.GoToRecord , , acNewRec
     Err.Clear                                                     '* add this
     
End Sub
0
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 1

Author Comment

by:njmatt
ID: 22825422
That gets rid of the error prompt, however does create a new record for editing.  
0
 
LVL 75
ID: 22825454
I assume you mean does 'not' ?

On the form you are trying to open, check the Form's Allow Additions property - It should be set to Yes - and well as Allow Edits.

mx
0
 
LVL 1

Author Comment

by:njmatt
ID: 22825465
Thanks, yea I meant not.  Yes, those settings are in place.  I have gone through a handful of posts on this issue to no avail.  
0
 
LVL 75
ID: 22825489
ok ... when the form opens, what DO you see ?

mx
0
 
LVL 1

Author Comment

by:njmatt
ID: 22825498
It opens up "frmProfile" to the first record in the DB with all related data...The navigation selectors on the bottom are enabled, however the "New (blank) record" button is not enabled.
0
 
LVL 75
ID: 22825532
That would only happen if:

1) Allow Additions was NO ... or
2) The Form's RecordSource is not updateable.

Can you Compact & Repair (to shrink the size), then zip up the MDB, then attach the file for upload here (using the 'Attach File function below) ... removing any sensitive data of course? And please give a clear explanation of exactly how to reproduce the problem.

mx
0
 
LVL 1

Author Comment

by:njmatt
ID: 22825564
I attached the file in my initial post.

Open "frmHome"
   -> Click on "Employee Database"
       -> Click on "+ Person"
          -> This will bring you to the Profile form where I am unable to add a new record.

Thanks.
0
 
LVL 75
ID: 22825882
Very strange.  As long as frmMain is open, the nav add button is grayed out on frmProfile.  IF you open frmProfile by itself, it's ok !

Trying to track this down.

mx
0
 
LVL 1

Author Comment

by:njmatt
ID: 22825896
Yea, I noticed that.  It is very strange.  I'm continuing my search for answers..I appreciate your help.
0
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 250 total points
ID: 22826011
Update:

The issue is the Record Source on frmMain

SELECT person.[last_name] FROM person;

If you remove that, frmProfile is ok.  

Werid
0
 
LVL 75
ID: 22826079
OK ... I found the problem.

On form Main - property sheet - Data tab - Records Locks is set to ALL records.  No can do.  Set to No Locks ... here and everywhere.

mx



0
 
LVL 1

Author Comment

by:njmatt
ID: 22826109
Wow, always something simple like that.  That does the trick.  Thanks.
0
 
LVL 75
ID: 22826173
A bit unusual that would be set to All Records!  

You are welcome.

mx
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Suggested Solutions

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

827 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