Entwr records with form and subform. (1 Viewer)

moi

Member
Local time
Today, 14:02
Joined
Jan 10, 2024
Messages
197
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.
 

Gasman

Enthusiastic Amateur
Local time
Today, 07:02
Joined
Sep 21, 2011
Messages
14,299
Put that code in the lostfocus of the last control of the subform perhaps?
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 02:02
Joined
May 21, 2018
Messages
8,529
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.
 

plog

Banishment Pending
Local time
Today, 01:02
Joined
May 11, 2011
Messages
11,646
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.
 

moi

Member
Local time
Today, 14:02
Joined
Jan 10, 2024
Messages
197
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..
 

moi

Member
Local time
Today, 14:02
Joined
Jan 10, 2024
Messages
197
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..
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 02:02
Joined
May 21, 2018
Messages
8,529
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.
 

LarryE

Active member
Local time
Yesterday, 23:02
Joined
Aug 18, 2021
Messages
591
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.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 02:02
Joined
Feb 19, 2002
Messages
43,275
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.
 

moi

Member
Local time
Today, 14:02
Joined
Jan 10, 2024
Messages
197
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

Top Bottom