Solved Form with tab control inside subform in datasheet view- how to update data (1 Viewer)

lacampeona

Registered User.
Local time
Today, 22:43
Joined
Dec 28, 2015
Messages
392
Hello
I have a form with several tab controls. Each tab control has a subform who is in datasheet view.

1.
From form frmGMKolutKapilare I choose ID record and then open a form with that specific ID.

1666800550779.png


2.
that form has several tab controls and On that form I have a button and I Use that button to copy (3) some fields from that specific ID 13 and enter new data.

1666800686290.png



4. I enter data in my new ID 14.
1666800875685.png



5.
How to automaticly update data when I finish entereing data in the form? Now i have to open and close and then I see the new record ID 14.

1666800942436.png
 

Attachments

  • 1666800829064.png
    1666800829064.png
    108.1 KB · Views: 70

lacampeona

Registered User.
Local time
Today, 22:43
Joined
Dec 28, 2015
Messages
392
Yes but where to put requery?
On which form? which event?
on close? on got focus? on current?
I try it and for now nothing ... :cautious:
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 16:43
Joined
Feb 19, 2002
Messages
43,298
Since you want to requery a sibling subform, the code would be:

Me.Parent.nameofsubformcontrol.Form.Requery

Put it in the AfterUpdate event of each subform and run a separate requery for each subform you want refreshed.

PS, tabs have nothing to do with anything when referencing subforms and controls. They are ignored.
 

lacampeona

Registered User.
Local time
Today, 22:43
Joined
Dec 28, 2015
Messages
392
Hi Pat
How I run separate requery?hmmmm
Now I put it on the AfterUpdate event on my first subform? and now?
 

Minty

AWF VIP
Local time
Today, 21:43
Joined
Jul 26, 2013
Messages
10,371
If you open the form as acDialog , the code on the calling form is paused until you close the first form.
So something like this in the frmGMKolutKapilare

Code:
DoCmd.OpenForm "yourSecondForm", acNormal, , WhereClauseGoesHere, acFormEdit, acDialog

Me.Requery

The Me.Requery won't happen until the second form is closed.
 
Last edited:

Minty

AWF VIP
Local time
Today, 21:43
Joined
Jul 26, 2013
Messages
10,371
Can you show your code for how you are opening the second form?
It shouldn't need to change, you just need to add the acDialog part to it.
 

lacampeona

Registered User.
Local time
Today, 22:43
Joined
Dec 28, 2015
Messages
392
Hi
yes
this is
hmmmmm
Private Sub IDKolut_Click()
DoCmd.OpenForm "frmVnosKolutaKapilare", , , "IDKolut = " & Me!IDKolut, acFormEdit
End Sub
 

Minty

AWF VIP
Local time
Today, 21:43
Joined
Jul 26, 2013
Messages
10,371
So the new version should be

Code:
Private Sub IDKolut_Click()

  DoCmd.OpenForm "frmVnosKolutaKapilare", , , "IDKolut = " & Me!IDKolut, acFormEdit , acDialog
  Me.Requery

End Sub
 

lacampeona

Registered User.
Local time
Today, 22:43
Joined
Dec 28, 2015
Messages
392
Ok
So the new version is
Private Sub IDKolut_Click()

DoCmd.OpenForm "frmVnosKolutaKapilare", , , "IDKolut = " & Me!IDKolut, acFormEdit , acDialog
Me.Requery

End Sub
what abut this you say earlier

I also have to use that? on the frmGMKolutKapilare Which event? hmmmm

DoCmd.OpenForm "yourSecondForm", acNormal, , WhereClauseGoesHere, acFormEdit, acDialog

Me.Requery
 

lacampeona

Registered User.
Local time
Today, 22:43
Joined
Dec 28, 2015
Messages
392
Thank you both Pat and Minty
I first try Pat solution and didnt work hmmm or maybe I didnt make it correct 🤔
and then I try Minty solution and now is working.
thank you experts
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 16:43
Joined
Feb 19, 2002
Messages
43,298
My suggestion didn't work because you are NOT using a subform. Subforms are forms that are embedded in other forms. You are using what we refer to as a "pop up" form and Minty told you that to do this correctly, you open the "pop up" as a Dialog. That stops all the code in the base form after the OpenForm action is performed. The code in the base form resumes AFTER the "pop up" form is closed and THEN the requery runs.

Minty has you requering the main form which requeries all the subforms also. Since you told me you were running the code in a subform, I gave you the code to requery a specific sibling form. Which of course you didn't actually have:( and so obviously the code wouldn't work.

Do you now see the difference between an actual subform and a "pop up form"?
 

lacampeona

Registered User.
Local time
Today, 22:43
Joined
Dec 28, 2015
Messages
392
Hi Pat
yes now I see the difference between an actual subform and a "pop up form".

I saved both solutions in my "collection" so If someday I will need i have also that solution.
thank you again for you explanation.
you experts are so nice and full of knowledge. You are like doctors you know exatly what is the reason and solution.
thank you
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 16:43
Joined
Feb 19, 2002
Messages
43,298
I need to edit my previous comment.

If you call the popup from a subform, the Me.Requery is running in THAT subform and therefore will NOT requery the main form or sibling forms. Context is everything. If you call the popup from sfrmA and the list that you want requeried is in the CONTROL named sfrmB, your sibling on the main form, then you need to either requery the main form:

Me.Parent.Requery

OR

You need to requery the specific subform.
Me.Parent.sfrmB.Form.Requery

Remember, the name of the subform is irrelevant although if you used the wizard to build the subform control, the Control's Name property is likely = the actual name of the subform as seen in the Navigation Pane.
 

Users who are viewing this thread

Top Bottom