Solved SetTempVar to Run Requery or Refresh on other form (1 Viewer)

Sarah.M

Member
Local time
Today, 14:26
Joined
Oct 28, 2021
Messages
335
Hi, Plz note, My VBA is disabled for security reason.
I can use only Expression builder, Macros, Queries, Tables, Forms and Reports only.
------------------------------------------------
I have 2 Forms
Form 1 is main form
Form 2 is a second form,
Try1
I add Macro on form 2 on close requery form 1, not working
Try2
Form 2 on close run Stand Alone macro to requery form 1, not working
Try3
I think SetTempVar is the solutionو How can I let SetTempVar to run rquerry command at form 1?
Form 1 I create a button on click I put SetTempVar Name: Req
I create submacro to Requery
and then in Form 2 on close I use TempVar!Req but it dose not fire the macro :(

plz help 🙏
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 19:26
Joined
May 7, 2009
Messages
19,230
if you can share a sample db of what these two forms do.
 

Mike Krailo

Well-known member
Local time
Today, 07:26
Joined
Mar 28, 2020
Messages
1,043
In VBA this would simply be in the After Update event of the subform. Can you try to create a macro for the after update and reference the main form requery there? We cannot help you with specifics since you provided none for us to work with.

From Microsoft help on requery macro action.

"If you want to requery a control that isn't on the active object, you must use the Requery method in a Visual Basic for Applications (VBA) module, not the Requery macro action or its corresponding Requery method of the DoCmd object."
 
Last edited:

Sarah.M

Member
Local time
Today, 14:26
Joined
Oct 28, 2021
Messages
335
if you can share a sample db of what these two forms do.
Thanks for replying !
After i added new order from NewOrderF and then click on close button Requery OrderF by useing SetTempVar
plz find the Sample
🙏
 

Attachments

  • TempVar.accdb
    896 KB · Views: 241

Sarah.M

Member
Local time
Today, 14:26
Joined
Oct 28, 2021
Messages
335
In VBA this would simply be in the After Update event of the subform. Can you try to create a macro for the after update and reference the main form requery there? We cannot help you with specifics since you provided none for us to work with.

From Microsoft help on requery macro action.

"If you want to requery a control that isn't on the active object, you must use the Requery method in a Visual Basic for Applications (VBA) module, not the Requery macro action or its corresponding Requery method of the DoCmd object."
Thanks for replying plz find the attached Sample I posted it
 

Mike Krailo

Well-known member
Local time
Today, 07:26
Joined
Mar 28, 2020
Messages
1,043
Sarah, I have no idea what you are trying to do in your sample DB. The OrdersF has a record source of OrdersQ which is essentially a select of the entire OrdersT table. You're other form NewOrderF has a record source of OrdersT. Since both forms have the same record source it is totally unclear what you are doing with this. Having an OrdersT table suggests that you have some product or service for customers to order. You're tables have to be established first before generating any forms. I suggest you get that worked out with some sample data before doing any forms. If you don't already know about normalization of data into separate tables, you should learn that first.
 

jdraw

Super Moderator
Staff member
Local time
Today, 07:26
Joined
Jan 23, 2006
Messages
15,379
Sarah,
How about telling us about the "business" this data base is suppose to support. You can give us the 30,000 ft version so we have some context in order to offer focused responses.
As was requested earlier - a sample database with instructions to highlight the issue would be helpful.
 

Sarah.M

Member
Local time
Today, 14:26
Joined
Oct 28, 2021
Messages
335
Thanks for replying
I mean I want SetTempVar to fire a macro in other form how can i do it?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:26
Joined
Oct 29, 2018
Messages
21,455
Thanks for replying
I mean I want SetTempVar to fire a macro in other form how can i do it?
VBA has a CallByName() function, not sure if macros have an equivalent.
 

Sarah.M

Member
Local time
Today, 14:26
Joined
Oct 28, 2021
Messages
335
Thanks for replying
Can SetTempVar refer to Submacro and then Submacro Fire a Embadded Macro or Stand alone Macro? If yes how 🙏
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:26
Joined
Oct 29, 2018
Messages
21,455
Thanks for replying
Can SetTempVar refer to Submacro and then Submacro Fire a Embadded Macro or Stand alone Macro? If yes how 🙏
TempVars are just global variables. They can only store values. They can't execute code/macro by themselves.
 

Mike Krailo

Well-known member
Local time
Today, 07:26
Joined
Mar 28, 2020
Messages
1,043
I mean I want SetTempVar to fire a macro in other form how can i do it?
This is not the mile high view of what you are actually trying to do that was requested by Jdraw. Setting a tempvar is just that, you set it to a value. This does nothing to trigger a macro in the other form (theDBguy beat me to that point). Could you please describe in English and not in code what you are really trying to do, then it will be more likely to get usable help. Otherwise, this will turn into a 50 post thread just trying to figure out what your overall goal is.

The problem I see with your example DB is that there is no table structure to support orders of any kind yet. You only have UsersT and OrdersT. If you really have orders, then you will need a few more tables minimum before you could even think about creating any forms. Are the people in the UsersT the customers that are ordering something? In order to order something, you need a product or service table and usually there would be a join table like OrderProductT or similar. If you have more of your table structure present in your example, things will be easier to help you with the forms.
 

Sarah.M

Member
Local time
Today, 14:26
Joined
Oct 28, 2021
Messages
335
Thanks for replying
I have a form on close I want Macro Action to trigger Embadded macro or Stand alone Macro for other Form
Macro trigger other Macro in other place
I am sorry 😞 I am trying hard to explain as much as I can
Thank you for your patience!
 
Last edited:

theDBguy

I’m here to help
Staff member
Local time
Today, 04:26
Joined
Oct 29, 2018
Messages
21,455
Thanks for replying
I have a form on close I want Macro Action to trigger Embadded macro or Stand alone Macro for other Form
Macro trigger other Macro
I am sorry 😞 I am trying hard to explain as much as I can
Thank you for your patience!
Probably easier to use a named (stand alone) macro. Don't think you can execute an embedded macro externally.
 

Sarah.M

Member
Local time
Today, 14:26
Joined
Oct 28, 2021
Messages
335
Thanks for replying
So how can I let the macro to trigger stand alone Macro on other form?
If I close the form I want stand alone Macro that belong to other form to be triggered?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:26
Joined
Oct 29, 2018
Messages
21,455
Thanks for replying
So how can I let the macro to trigger stand alone Macro on other form?
If I close the form I want stand alone Macro that belong to other form to be triggered?
Hi. Stand alone (named) macros don't belong to any form. So, you should be able to simply call them from anywhere by using the RunMacro action.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 19:26
Joined
May 7, 2009
Messages
19,230
see if this is what you meant.
see the macro on the button and also on the AfterUpdate event of the form.
 

Attachments

  • TempVar.accdb
    896 KB · Views: 309

Users who are viewing this thread

Top Bottom