Update field on calling form (1 Viewer)

JohnPapa

Registered User.
Local time
Today, 09:54
Joined
Aug 15, 2010
Messages
954
I have a form A which displays, among other things, the value of a field based on some table values.

Form A calls Form B which calls Form C which changes the table values, which affects the field value on Form A.

I tried using acDialog when I open Form B and Form C, but when I do this Form C appears behind Form B. I also tried setting Popup to true for the forms but that did not help.

Essentially what I want to do is execute some code in Form A once I return from Forms B & C, to update the specific field on Form A.
 

bob fitz

AWF VIP
Local time
Today, 07:54
Joined
May 23, 2011
Messages
4,726
I tried using acDialog when I open Form B and Form C, but when I do this Form C appears behind Form B...........
If both B and C are opened, using the acDialog argument, then whichever is opened last should stay "On Top". Double-check that you did set the acDialog argument of DoCmd.OpenForm when opening both B and C.
 

JohnPapa

Registered User.
Local time
Today, 09:54
Joined
Aug 15, 2010
Messages
954
If both B and C are opened, using the acDialog argument, then whichever is opened last should stay "On Top". Double-check that you did set the acDialog argument of DoCmd.OpenForm when opening both B and C.
Yes it worked. I swear I tried it many times. Maybe my pc was in a weird state, as I was having other problems as well.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 07:54
Joined
Sep 12, 2006
Messages
15,656
The simplest way to update the value on form A is Me.requery, although it depends what processing you need to do. Also me.requery might change the active record shown by form A.

The value may even change without doing anything at all.
 

JohnPapa

Registered User.
Local time
Today, 09:54
Joined
Aug 15, 2010
Messages
954
The simplest way to update the value on form A is Me.requery, although it depends what processing you need to do. Also me.requery might change the active record shown by form A.

The value may even change without doing anything at all.
There is some code that is executed in the Open event of the form, so Form_Open(0) could be used.
 

moke123

AWF VIP
Local time
Today, 02:54
Joined
Jan 11, 2013
Messages
3,920
Something like this maybe?

Code:
Dim WithEvents MyForm2 As Access.Form

Private Sub Command0_Click()

    DoCmd.OpenForm "Form2"

    Set MyForm2 = Forms("Form2")
    MyForm2.OnClose = "[Event Procedure]"
    MyForm2.Modal = True

End Sub

Private Sub MyForm2_Close()

    MsgBox "Do something here when form2 closes"

    Set MyForm2 = Nothing

End Sub
 

Attachments

  • 3forms.accdb
    436 KB · Views: 42

MajP

You've got your good things, and you've got mine.
Local time
Today, 02:54
Joined
May 21, 2018
Messages
8,529
Here is a little more explanation of when and why to use ACDIALOG or what @moke123 suggests, and what are the impacts of each.
ACDIALOG does not equate to simply modal, pop up. There is more to it.
 

Users who are viewing this thread

Top Bottom