Stay on current record to edit

D

deb

I have a total of 4 forms, nested...
f0Site, f1Customer, f2PlantSub, f3UnitSub

On the main form (f0Site) I have an edit button that when clicked it sets
all forms for edit. see below code

Me!f1Customer.Form.AllowAdditions = True
Me!f1Customer.Form!f2PlantSub.Form.AllowAdditions = True
Me!f1Customer.Form!f2PlantSub.Form!f3UnitSub.Form.AllowAdditions = True

Me.AllowEdits = True
Me!f1Customer.Form.AllowEdits = True
Me!f1Customer.Form!f2PlantSub.Form.AllowEdits = True
Me!f1Customer.Form!f2PlantSub.Form!f3UnitSub.Form.AllowEdits = True

If I am on a sub record of a sub form and click the Edit button, I am taken
back to the first record. How can I stay on the current record showing at
the time the Edit button is clicked.

For instance.

I am on Site 1 record, Customer 1 record, Plant 1 record and Unit 3 record.
When I click the Edit button it takes me to Site 1 record, Customer 1
record, Plant 1 record and Unit 1 record.

I want to stay on the Unit 3 record and make the edits.

Thanks
 
W

Wayne-I-M

Hi

You have not given enough info for a full answer but the basics are

(THis is a cheat that seems work really well) - create a unbound box on the
main form call it hiddentxt. YOu would then the vaule that you need (the ID
from the subform to this (OnClick of the subform) - you have to do this is
use this cheat as you cant access the record without and you get an error
(sorry don't know the right english to say that but hope you understand)

Forms!MainFormName!hiddentxt = Forms!MainFormName!SubformName.Form!ID
Forms!MainFormName.SetFocus
Forms!MainFormName!hiddentxt.SetFocus
Set rst = Me("SubFormName").Form.RecordsetClone
rst.FindFirst "ID = " & Forms!MainFormName!SubformName.Form!ID
Me("SubFormName").Form.Bookmark = rst.Bookmark

This will set the record to the same as was you working on (the subform) to
the main form

This bit
Forms!MainFormName!hiddentxt.SetFocus
is important for the cheat as you can't set the focus to the record (and the
hiddentxt is unbound so its OK) or you get another error
 
D

deb

I am sorry, I do not understand.

My main form is f0Site, the nested sub forms are f1Customer, f2PlantSub,
f3UnitSub

What is the Hiddentxt control source?
Do I need the code for each subform?
Where is the code placed? Edit>On Click? On Current?...

I will be glad to supply any other info you need, just let me know.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top