Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 11-10-2019, 03:25 AM   #1
GK in the UK
Newly Registered User
 
Join Date: Dec 2017
Posts: 94
Thanks: 13
Thanked 0 Times in 0 Posts
GK in the UK is on a distinguished road
OpenArgs not evaluated in Current event

Is there any reason why I shouldn't evaluate OpenArgs in the current event ? As far as I can tell, it's not evaluated in there. Normally I have it in the load event but there's a reason I want it in Current, I want to refresh the contents of an already open form and I need to get the criteria for the opened record.


Edit: Title should read: OpenArgs not re-evaluated on subsequent OpenForm of already open form


Last edited by GK in the UK; 11-10-2019 at 05:11 AM. Reason: Clarity of title
GK in the UK is offline   Reply With Quote
Old 11-10-2019, 04:00 AM   #2
Gasman
Enthusiastic Amateur
 
Gasman's Avatar
 
Join Date: Sep 2011
Location: Swansea, South Wales,UK
Posts: 4,505
Thanks: 439
Thanked 836 Times in 807 Posts
Gasman is a jewel in the rough Gasman is a jewel in the rough Gasman is a jewel in the rough
Re: OpenArgs not evaluated in Current event

Wouldn't a requery do that.?

Store the OpenArgs to a form global variable on load if it is not available in any other event.?
__________________
Access novice. Sometimes trying to give something back.
Access 2007

Please, please use code tag # when posting code snippets

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Gasman is offline   Reply With Quote
Old 11-10-2019, 04:11 AM   #3
Gasman
Enthusiastic Amateur
 
Gasman's Avatar
 
Join Date: Sep 2011
Location: Swansea, South Wales,UK
Posts: 4,505
Thanks: 439
Thanked 836 Times in 807 Posts
Gasman is a jewel in the rough Gasman is a jewel in the rough Gasman is a jewel in the rough
Re: OpenArgs not evaluated in Current event

I've just tested it and it is available in the On Current event?

__________________
Access novice. Sometimes trying to give something back.
Access 2007

Please, please use code tag # when posting code snippets

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Gasman is offline   Reply With Quote
Old 11-10-2019, 05:03 AM   #4
GK in the UK
Newly Registered User
 
Join Date: Dec 2017
Posts: 94
Thanks: 13
Thanked 0 Times in 0 Posts
GK in the UK is on a distinguished road
Re: OpenArgs not evaluated in Current event

Well I agree it's evaluated in Current when the form is first opened, that's where my OpenArgs evaluation code is.

So let's say I open frmInvoice with OpenArgs A then frmInvoice opens with OpenArgs A
If I close frmInvoice and reopen it with OpenArgs B then frmInvoice opens with OpenArgs B

But if I now leave frmInvoice open, and do OpenForm with OpenArgs A , frmInvoice doesn't re-evaluate OpenArgs and it's stuck on OpenArgs B. Open and Load don't fire so evaluation is in Current event.

No matter how many times I OpenForm with OpenArgs A, it's stuck on OpenArgs B. Even though evaluation is in Current. I have to close frmInvoice and start again which isn't what I want.

Ah, someone on StackOverflow says the same thing. No re-evaluation if the form is open. Need Plan B
GK in the UK is offline   Reply With Quote
Old 11-10-2019, 05:27 AM   #5
isladogs
High Noon Moderator
 
isladogs's Avatar
 
Join Date: Jan 2017
Location: Somerset, UK
Posts: 11,226
Thanks: 115
Thanked 3,071 Times in 2,789 Posts
isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold isladogs is a splendid one to behold
Re: OpenArgs not evaluated in Current event

I've always used OpenArgs to set the form conditions when first loaded.
I don't believe it's intended for any other purpose.
https://docs.microsoft.com/en-us/off....Form.OpenArgs

For your situation why not just set filter criteria to the selected item e.g.
Me.Filter = ...some criteria
Me.FilterOn=True

Or use a subform filtered to the selection.
Lots of examples of both of these elsewhere in this forum
__________________
If this answer has helped, please click the Thanks button and/or click the 'reputation scales' symbol on the left.

Colin (Mendip Data Systems)
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


Website links:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
,
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


Common sense and a sense of humour are the same thing, moving at different speeds. (Clive James - RIP)
isladogs is offline   Reply With Quote
Old 11-10-2019, 05:48 AM   #6
GK in the UK
Newly Registered User
 
Join Date: Dec 2017
Posts: 94
Thanks: 13
Thanked 0 Times in 0 Posts
GK in the UK is on a distinguished road
Re: OpenArgs not evaluated in Current event

Isn't a filter for record selection ? The child form is frmInvoice and is for a single record specified in WhereCondition.

The criteria is a) is this invoice editable (as opposed to finalised) and b) is this a Sales or Purch invoice, because the same frmInvoice deals with both and it needs to know how to display credit values - all to do with double entry book keeping)

For things like this I sometimes get the called form (frmInvoice) to read some values from hidden text boxes in the calling form. But in this case, I want to be able to open frmInvoice either from the index form, or stand alone from some other routine. So the criteria needs to come in via OpenArgs. frmIndex has to be a 'stand alone' object (if that's the right terminology)

The workaround is to close the form and immediately open it again. Seems like an ugly fix and it's really slow to browse the index file of invoices.


Thanks for your suggestions
GK in the UK is offline   Reply With Quote
Old 11-10-2019, 05:52 AM   #7
Gasman
Enthusiastic Amateur
 
Gasman's Avatar
 
Join Date: Sep 2011
Location: Swansea, South Wales,UK
Posts: 4,505
Thanks: 439
Thanked 836 Times in 807 Posts
Gasman is a jewel in the rough Gasman is a jewel in the rough Gasman is a jewel in the rough
Re: OpenArgs not evaluated in Current event

If the form is already open, doesn't it just go to the form when you try a second open statement.?

You could use a Tempvar instead.?

If you want the form open multiple times, you need to setup a collection.?

Allen Brownes site shows how and it has been mentioned on here at least once.?

Quote:
Originally Posted by GK in the UK View Post
Well I agree it's evaluated in Current when the form is first opened, that's where my OpenArgs evaluation code is.

So let's say I open frmInvoice with OpenArgs A then frmInvoice opens with OpenArgs A
If I close frmInvoice and reopen it with OpenArgs B then frmInvoice opens with OpenArgs B

But if I now leave frmInvoice open, and do OpenForm with OpenArgs A , frmInvoice doesn't re-evaluate OpenArgs and it's stuck on OpenArgs B. Open and Load don't fire so evaluation is in Current event.

No matter how many times I OpenForm with OpenArgs A, it's stuck on OpenArgs B. Even though evaluation is in Current. I have to close frmInvoice and start again which isn't what I want.

Ah, someone on StackOverflow says the same thing. No re-evaluation if the form is open. Need Plan B

__________________
Access novice. Sometimes trying to give something back.
Access 2007

Please, please use code tag # when posting code snippets

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Gasman is offline   Reply With Quote
Old 11-10-2019, 06:09 AM   #8
GK in the UK
Newly Registered User
 
Join Date: Dec 2017
Posts: 94
Thanks: 13
Thanked 0 Times in 0 Posts
GK in the UK is on a distinguished road
Re: OpenArgs not evaluated in Current event

It's the same instance of frmInvoice. I don't want another instance (though I will at some point so I'll have to understand that)

Thinking about it some more, I can probably determine the criteria from the document itself. Which is probably a much better way to do it but at least I now know the limitations of OpenArgs.
GK in the UK is offline   Reply With Quote
Old 11-10-2019, 06:32 AM   #9
Gasman
Enthusiastic Amateur
 
Gasman's Avatar
 
Join Date: Sep 2011
Location: Swansea, South Wales,UK
Posts: 4,505
Thanks: 439
Thanked 836 Times in 807 Posts
Gasman is a jewel in the rough Gasman is a jewel in the rough Gasman is a jewel in the rough
Re: OpenArgs not evaluated in Current event

I do not think that is a limitation as you are not opening the form again?

A TempVar would probably do the job.?
__________________
Access novice. Sometimes trying to give something back.
Access 2007

Please, please use code tag # when posting code snippets

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Gasman is offline   Reply With Quote
Old 11-11-2019, 04:39 AM   #10
gemma-the-husky
Super Moderator
 
gemma-the-husky's Avatar
 
Join Date: Sep 2006
Location: UK
Posts: 13,814
Thanks: 56
Thanked 1,028 Times in 994 Posts
gemma-the-husky is a name known to all gemma-the-husky is a name known to all gemma-the-husky is a name known to all gemma-the-husky is a name known to all gemma-the-husky is a name known to all gemma-the-husky is a name known to all
Re: OpenArgs not evaluated in Current event

Obviously your problem is trying to refresh the data in an open form, where the form has been opened to show different data.

I would be inclined to find a way to force the popup form to close before opening it again - if you want to do this with openargs.

if you do it with a global variable (instead of the openargs) then you could call a function IN the popup form, to reload the data based on the global setting. However, you then maybe have an issue if the popup form is dirty.

Therefore, I would be inclined to close the popup form before opening it to a new record, (or find another way to accomplish the same thing)
__________________
Dave (Male!)
Gemma was my dog

if a poster helps you, please click the scales at the bottom left of this posting, or use the thanks button alongside.
gemma-the-husky is offline   Reply With Quote
Old 11-11-2019, 06:56 PM   #11
Pat Hartman
Super Moderator
 
Join Date: Feb 2002
Location: Stratford,Ct USA
Posts: 28,298
Thanks: 15
Thanked 1,597 Times in 1,517 Posts
Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all
Re: OpenArgs not evaluated in Current event

This is the reason that I hide formA when I open formB so that the user has to close formB before reopening it. If both formA and formB need to be visible, then I open formB as a dialog so that formA cannot get the focus while formB is still open.

When none of those will work, I have formA check to see if formB is already open and if it is, close it first. Then reopen it with the new openArg.
__________________
Bridge Players Still Know All the Tricks
Pat Hartman is offline   Reply With Quote
Old 11-11-2019, 07:09 PM   #12
Micron
AWF VIP
 
Join Date: Oct 2018
Location: Ontario, Canada
Posts: 1,186
Thanks: 10
Thanked 226 Times in 214 Posts
Micron has a spectacular aura about Micron has a spectacular aura about
Re: OpenArgs not evaluated in Current event

Quote:
then I open formB as a dialog so that formA cannot get the focus while formB is still open.
I think you mean modal? Dialog is a border property; popup and modal are form properties.
__________________
Sometimes I just roll my eyes out loud...
Windows 10; Office 365 (Access 2016)
Micron is offline   Reply With Quote
Old 11-11-2019, 07:18 PM   #13
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 6,394
Thanks: 58
Thanked 1,403 Times in 1,384 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: OpenArgs not evaluated in Current event

Quote:
Originally Posted by Micron View Post
I think you mean modal? Dialog is a border property; popup and modal are form properties.
Hi Micron. I think maybe Pat was referring to something else. Take a look at this article. Cheers!
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is online now   Reply With Quote
Old 11-11-2019, 07:20 PM   #14
Pat Hartman
Super Moderator
 
Join Date: Feb 2002
Location: Stratford,Ct USA
Posts: 28,298
Thanks: 15
Thanked 1,597 Times in 1,517 Posts
Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all
Re: OpenArgs not evaluated in Current event

Yes, Modal. Thanks Micron and theDBguy
__________________
Bridge Players Still Know All the Tricks
Pat Hartman is offline   Reply With Quote
Old 11-11-2019, 07:21 PM   #15
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 6,394
Thanks: 58
Thanked 1,403 Times in 1,384 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: OpenArgs not evaluated in Current event

Quote:
Originally Posted by Pat Hartman View Post
Yes, Modal. Thanks Micron and theDBguy
Oops, sorry for jumping in...

__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is online now   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Too Complex to be evaluated vbbbmom Queries 1 12-02-2014 11:43 AM
Pass Current Record OpenArgs. ChrisO Sample Databases 0 06-05-2012 04:48 PM
Event for reports similar to the forms Current event KeithG Reports 1 03-20-2008 11:11 AM
VBA constant in sql is it only evaluated once? petebob796 Queries 4 08-14-2007 12:25 AM
Events - What is evaluated first. Mark Liddle Forms 5 06-23-2001 01:36 AM




All times are GMT -8. The time now is 07:52 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World