Entwr records with form and subform.

moi

Member
Local time
Today, 23:31
Joined
Jan 10, 2024
Messages
273
Dear all,

How would i make my data entry forms (main form + subform) that after filling the last control of subform it clears the main form and subform and goes to the first control of mainform ready to accept new record..

Many thanks.
 
Put that code in the lostfocus of the last control of the subform perhaps?
 
How would i make my data entry forms (main form + subform) that after filling the last control of subform it clears the main form and subform and goes to the first control of mainform ready to accept new record.
You can only add one child record before starting a new main record? That design seems strange. If it is a one to one you would not need a subform.
 
Gasman gave you the correct answer, but why would you want to do this?

after filling the last control of subform it clears the main form and subform and goes to the first control of mainform ready to accept new record.

Sounds like a recipe for lots of user complaints and misunderstandings.
--> I mistyped the second to last input, but before I could go back to it and correct it the whole thing was gone.
--> I entered it 5 times because every time I was almost done it disappeared on me.
 
You can only add one child record before starting a new main record? That design seems strange. If it is a one to one you would not need a subform.
Indeed, before i proceeded to subform, mainform already filled with data related to its subform data..
 
Gasman gave you the correct answer, but why would you want to do this?



Sounds like a recipe for lots of user complaints and misunderstandings.
--> I mistyped the second to last input, but before I could go back to it and correct it the whole thing was gone.
--> I entered it 5 times because every time I was almost done it disappeared on me.
I am unable to see the answer of gasman, can you pls assist me, i am newbie to ms access, i am not good in coding yet..
 
ndeed, before i proceeded to subform, mainform already filled with data related to its subform data..
Not my question. Most people have a subform to add multiple related child records. You are asking that as soon as a child record is added it goes to a new main record. That means you will only ever want one child record? In that case I doubt your tables are designed correctly. It is not unheard of but 1:1 relationships are rare and not usually requiring a subform.
 
If you really want to pass control back to the main form and then go to a new record, you can set focus to one of the main forms textboxes and then go to a new record. So you can put this code in the subforms control textbox After Update Event:

Forms![Main Form Name]![Main Form Control Textbox].SetFocus
DoCmd.GoToRecord acActiveDataObject, , acNewRec

You should use caution when doing this as has been already mentioned.
 
When the request makes no sense, it is really better for us to actually clarify what is going on rather than just offering "solutions" to the unknown problem.
 
If you really want to pass control back to the main form and then go to a new record, you can set focus to one of the main forms textboxes and then go to a new record. So you can put this code in the subforms control textbox After Update Event:

Forms![Main Form Name]![Main Form Control Textbox].SetFocus
DoCmd.GoToRecord acActiveDataObject, , acNewRec

You should use caution when doing this as has been already mentioned.
Many thanks larry.. Am Iearning through your helps..
 

Users who are viewing this thread

Back
Top Bottom