UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Parent Form Will Not Reload, After Currentdb.execute (inside A Dialogue), Access 2016    
 
   
robertkjr3d
post Nov 14 2017, 09:05 AM
Post#1



Posts: 9
Joined: 14-November 17



I have a parent-form... They click a 'hypelink' which opens a dialogue-form:
CODE
Private Sub lkElevate_Click()
    DoCmd.OpenForm "Elevate", WindowMode:=acDialog
    DoEvents
    Me.Requery
    DoEvents
    Me.Refresh
    DoCmd.Close
    DoCmd.OpenForm "DashBoard"
End Sub


As you can see... I'm waiting for the 'Dialogue' 'Elevate' to complete. In fact I've tested this, it does. Before hitting the 'Me.Requery', or other lines of code.

Now Inside of the 'Elevate' form: (the important part anyway)
CODE
            CurrentDb.Execute ("update Members set .....")
            'Refresh the opening screen   --- Abbreviated for your support pleasure
            DoCmd.Close


From the earlier bit of code, after the 'DoCmd.OpenForm', I've tried all manner of different things. Even closing and reopening. Still the 'DashBoard' comes up with the old data. It does not even hit the 'Form-Load', even with 'close' and 'reopen'. The only way to accomplish this, is to manually close the form and reopen it.

help... Why can't I get the form to reload the newly updated data? How many other ways can I ask it to 'reload'?
Go to the top of the page
 
Doug Steele
post Nov 14 2017, 10:44 AM
Post#2


UtterAccess VIP
Posts: 21,445
Joined: 8-January 07
From: St. Catharines, ON (Canada)


welcome2UA.gif
I have to confess I'm having problems understanding your exact situation.

On which form is lkElevate? Is it form DashBoard, or some other form?

And what's the "opening screen" referred to in the comment about what's in form Elevate? (incidentally, saying something like "Abbreviated for your support pleasure" is seldom a good idea. Just because you don't think what it's doing it relevant doesn't mean it isn't...)

Does anything change if you put a DoEvents before the DoCmd.Close in form Elevate?


--------------------
Go to the top of the page
 
robertkjr3d
post Nov 14 2017, 02:22 PM
Post#3



Posts: 9
Joined: 14-November 17



Sorry I didn't realize I was so cryptic.
lkElevate is on form-Dashboard (it is the parentform). The Click-Code for lkElevate is inside form-Dashboard. It is the opening screen of the project.
Inside the lkElevate's click-code I tried all manner of stuff trying to refreah 'DashBoard' after Form-Elevate ran and closed.
Go to the top of the page
 
River59
post Nov 14 2017, 02:57 PM
Post#4



Posts: 1,319
Joined: 7-April 10
From: Detroit, MI


I don't see where you ever closed the Dashboard. You open and refresh form Elevate then close it but you don't close and re-open the main dashboard (nor refresh it), but then maybe I'm missing it.
This post has been edited by River59: Nov 14 2017, 02:57 PM

--------------------
Remember ... Armstrong, Aldrin and Collins flew to the moon and back with a computer system less complex than a modern, programmable toaster ...
Go to the top of the page
 
Doug Steele
post Nov 14 2017, 03:21 PM
Post#5


UtterAccess VIP
Posts: 21,445
Joined: 8-January 07
From: St. Catharines, ON (Canada)


While I would expect the Me.Requery in sub lkElevate_Click to work, what about trying to requery form DashBoard from form Elevate before the DoCmd.Close statement?

CODE
  Forms![DashBoard].Requery

(BTW, the line of code DoCmd.OpenForm "DashBoard" in sub lkElevate_Click will never be executed, since the previous line closes the form and thereby stops its code from running.)

--------------------
Go to the top of the page
 
robertkjr3d
post Nov 14 2017, 03:49 PM
Post#6



Posts: 9
Joined: 14-November 17



Just tried your solution it did not work.... Forms![DashBoard].Requery in the "Elevate" form.
And by the way this line is incorrect: '(BTW, the line of code DoCmd.OpenForm "DashBoard" in sub lkElevate_Click will never be executed, since the previous line closes the form and thereby stops its code from running.)

If it did not, how is it, that the Dashboard page still comes back up? Just by magic?

Indeed if I comment that last line out, the application closes entirely. Because that was the last form open. I'll give you the benefit of your expert doubt and say maybe; This is a different behavior between how 2016 operates, and some previous versions?
This post has been edited by robertkjr3d: Nov 14 2017, 03:54 PM
Go to the top of the page
 
River59
post Nov 14 2017, 03:57 PM
Post#7



Posts: 1,319
Joined: 7-April 10
From: Detroit, MI


I wrote a small function that opened and closed my main form ("Audit Results"). In your case it would be your Dashboard.

At the end of your code call the function.

Call ResetMain

Public Function ResetMain()

DoCmd.SetWarnings False
DoCmd.Close acForm, "AuditResults"
DoCmd.OpenForm "AuditResults"
DoCmd.SetWarnings True
End Function

This should close then re-open the Dashboard. It is so fast that the user only sees a quick blip on the screen. This should allow the Dashboard to be refreshed.

--------------------
Remember ... Armstrong, Aldrin and Collins flew to the moon and back with a computer system less complex than a modern, programmable toaster ...
Go to the top of the page
 
Doug Steele
post Nov 14 2017, 04:12 PM
Post#8


UtterAccess VIP
Posts: 21,445
Joined: 8-January 07
From: St. Catharines, ON (Canada)


Glad you found a solution.

When you said
QUOTE
Just tried your solution it did not work.... Forms![DashBoard].Requery in the "Elevate" form.
what happened? Did you get an error, or was it simply a case of nothing happening?

I noticed that you used DashBoard in your previous samples, but in your last sample, you called the form AuditResults. Which is it?

--------------------
Go to the top of the page
 
tina t
post Nov 14 2017, 04:12 PM
Post#9



Posts: 5,184
Joined: 11-November 10
From: SoCal, USA


QUOTE
Private Sub lkElevate_Click()
DoCmd.OpenForm "Elevate", WindowMode:=acDialog
DoEvents
Me.Requery
DoEvents
Me.Refresh
DoCmd.Close
DoCmd.OpenForm "DashBoard"
End Sub

try adding the following to the above procedure, as

CODE
Private Sub lkElevate_Click()
    DoCmd.OpenForm "Elevate", WindowMode:=acDialog
    DoCmd.SelectObject acForm, "DashBoard"
    DoEvents
    Me.Requery
    DoEvents
    Me.Refresh
    DoCmd.Close
    DoCmd.OpenForm "DashBoard"
End Sub

hth
tina

--------------------
"you can't take the sky from me"
Go to the top of the page
 
robertkjr3d
post Nov 14 2017, 04:13 PM
Post#10



Posts: 9
Joined: 14-November 17



Re: River59 - I tried this 'ResetMain()' code both in DashBoard and inside a Module.
It does not work. There is a fundamental caching of the form-data going on. It still does not ever 'again' hit the Form_Load.

So I tried breaking the Form_load, and changing it to a 'Call initial_load'...

CODE
Private Sub lkElevate_Click()
    DoCmd.OpenForm "Elevate", WindowMode:=acDialog
    ResetMain
    Call initial_load
End Sub


But then guess what happens. Inside 'initial_load', it does not even recognize access-form-elements to change them. This is getting weirder.
This post has been edited by robertkjr3d: Nov 14 2017, 04:20 PM
Go to the top of the page
 
robertkjr3d
post Nov 14 2017, 04:15 PM
Post#11



Posts: 9
Joined: 14-November 17



Doug Steele... Do not mix me up with 'River59' who spoke of 'AuditResults'
'Requery' seldom produces an error. But I don't actually see any requery of the data occurring.
This post has been edited by robertkjr3d: Nov 14 2017, 04:25 PM
Go to the top of the page
 
robertkjr3d
post Nov 14 2017, 04:18 PM
Post#12



Posts: 9
Joined: 14-November 17



Tina... 'Nope thank you for playing Mr. Dalton' -- Dead Poets Society
Go to the top of the page
 
Doug Steele
post Nov 14 2017, 11:22 PM
Post#13


UtterAccess VIP
Posts: 21,445
Joined: 8-January 07
From: St. Catharines, ON (Canada)


What is initial_load? Is it a routine associated with a form's class, or is it in a stand-alone module? What's the code in it?

--------------------
Go to the top of the page
 
robertkjr3d
post Nov 15 2017, 07:06 AM
Post#14



Posts: 9
Joined: 14-November 17



hold, on I may have something... editing
This post has been edited by robertkjr3d: Nov 15 2017, 07:10 AM
Go to the top of the page
 
robertkjr3d
post Nov 15 2017, 07:26 AM
Post#15



Posts: 9
Joined: 14-November 17



Ok... I've found the solution:
Here's what my lkElevate_Click() should look like:

CODE
Private Sub lkElevate_Click()
    DoCmd.OpenForm "Elevate", WindowMode:=acDialog
    Call fillUserData
    Me.Requery
    Call initial_load
End Sub


I had forgot to re-call 'fillUserData()'. Your question Doug indirectly, actually triggered my solution. It is a module that reloads the globals. You asked about 'initial_load'. I didn't originally have it when I started this question, but I decided to keep it, because I realized that when I want 'DashBoard' to reload, I couldn't get it's Form-Load to run. So I did this:

CODE
Private Sub Form_Load()
    Call initial_load
End Sub

Private Sub initial_load()
    Me.lbCurrentUser.Caption = "CURRENT USER: " & gblUserName
    Me.lbRole.Caption = "ROLE: " & gblUserRole
    lkSettings.Visible = True
    lkElevate.Visible = True
    
    If gblUserRole = "Administrator" Then
        lkElevate.Visible = False
    Else
        'Not Administrator
        If gblUserRole = "Manager" Then
        Else
            'Not Manager either
            lkSettings.Visible = False
        End If
    End If
End Sub


Then from the lkElevate it will recall it. No longer do I have to 'Close' and 'Reopen' the form. I'm also not receiving any errors.
not calling fillUserData() was my dumness from the beginning...
This post has been edited by robertkjr3d: Nov 15 2017, 07:33 AM
Go to the top of the page
 
Doug Steele
post Nov 15 2017, 08:13 AM
Post#16


UtterAccess VIP
Posts: 21,445
Joined: 8-January 07
From: St. Catharines, ON (Canada)


Glad you got it working. You may have done more work than is necessary though. You should have been able simply to use Call Form_Load.

--------------------
Go to the top of the page
 
robertkjr3d
post Nov 15 2017, 08:32 AM
Post#17



Posts: 9
Joined: 14-November 17



yup... kudos! Thanx
It's been too long since I've been away from VBA.
This post has been edited by robertkjr3d: Nov 15 2017, 08:34 AM
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    22nd November 2017 - 11:29 AM