Link to home
Start Free TrialLog in
Avatar of njmatt
njmatt

asked on

Create New Record using Command button on Separate form

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
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Can  you post the code for the command button?

mx
Avatar of njmatt
njmatt

ASKER

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

Quick fix:

Private Sub cmdAddNew_Click()
     DoCmd.OpenForm "frmProfile"
     On Error Resume Next                                '*** add this
     DoCmd.GoToRecord , , acNewRec
     Err.Clear                                                     '* add this
     
End Sub
Avatar of njmatt

ASKER

That gets rid of the error prompt, however does create a new record for editing.  
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
Avatar of njmatt

ASKER

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.  
ok ... when the form opens, what DO you see ?

mx
Avatar of njmatt

ASKER

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.
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
Avatar of njmatt

ASKER

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.
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
Avatar of njmatt

ASKER

Yea, I noticed that.  It is very strange.  I'm continuing my search for answers..I appreciate your help.
ASKER CERTIFIED SOLUTION
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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



Avatar of njmatt

ASKER

Wow, always something simple like that.  That does the trick.  Thanks.
A bit unusual that would be set to All Records!  

You are welcome.

mx