MS Access - Form - Open new form with previous form IF for Edit Record

Hey,

I have a form in which user search for record, this form have a subform which is a datasheet  in which the required search show up. Then there is a button as Edit Record which open new form for editing. I have 9 fields in subform, when user select record and click edit button the new form which open up shows the previous 8 fields except one field "ID" which is always opening as a new record, i want the ID to be  from the previous form not the new record. I have set Data Entry to be Yes which is required in my form, is there a way to get ID from previous form with data entry to yes.

Any help would be appreciated.

Thank you.
LVL 1
WSStudentAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Anders Ebro (Microsoft MVP)Microsoft DeveloperCommented:
As you open the form, pass in the ID you want to use, as an OpenArgs
docmd.OpenForm "frm_name",,,,acFormAdd,,me.ID

Open in new window


In the LOAD even of your form, you then read the OpenArgs.
Private Sub Form_Load()
  me.SomeTextbox.DefaultValue=Me.OpenArgs
end Sub

Open in new window


Note that if your form is allready open in design mode (because you are busy designing) then the OpenArgs will not work. So if you make changes to your form, make sure to close it fully before testing.
0
WSStudentAuthor Commented:
It's not working, any idea why? still it show id as new .
0
Anders Ebro (Microsoft MVP)Microsoft DeveloperCommented:
If it shows ID as new, it is because the field is bound to an AUTONUMBER field, where you can't assign ID's through the GUI interface.
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

WSStudentAuthor Commented:
yes it is an autonumber field , isn't it possible through VBA? what if i put Data entry to no?
0
mbizupCommented:
Is there a particular reason you need the Data Entry property to be 'Yes'?  If Data Entry is set to 'Yes', the form will open for the user to enter NEW records which as Anders said, will display NEW for the AutoNumber ID as they are created:

Data Entry Property

If you want to open a form to edit an EXISTING record, you would use a Where Condition when opening the form in VBA, with the DataEntry property set to No:

DoCmd.OpenForm "YourFormName", WhereCondition := "ID = " & Me.YourIDFieldName

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
WSStudentAuthor Commented:
i just want to open it to Data Entry form so that i could get values for all the fields from previous form. I am using Default Value property for 8 fields and if i turn Data Entry to No it doesn't work. that's the only reason behind this.
0
WSStudentAuthor Commented:
Thank you everyone :)

i turn off the Data Entry property and for ID i use the code mark as best solution with the rest field using Default Values from previous form.

Thanks again.
0
mbizupCommented:
Humm.... Test that a bit to make sure it is really what you are looking for (I'm not 100% clear on your goal here).  If you are actually trying to 'Copy an existing record to a new record', there are plenty of examples on the web.  If you still need assistance, you can use the 'report question' button to ask a moderator to reopen the question.
1
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.