If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Referencing forms and fields
I would like to reuse macros across many forms but i do not know the syntax
that would allow me to do so. For example, I have a macro that uses setvalue to change the value of a field if another field's value changes. The form field reference is [Forms]![f_events_and_shows_ds]![f_bookings_all].[Form]![entered_date_time]. I would like to invoke the same event in two forms but at present, i have to create (and maintain) two versions of the macro. Can you tell me what the syntax is that would allow me to replace the form name with the current form name (say) and is there somewhere that i could go on the web that would help me reference this area. |
#2
|
|||
|
|||
Referencing forms and fields
I think that you'll need to do this in code, where you can use a form name
as an argument: Public Function DoSomething(frm As Form) If you put the function in a standard module, you can use it just like a macro, by setting the AfterUpdate event like: = DoSomething([Forms]![ThisForm]) -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "Daniel Jacobs" wrote in message ... I would like to reuse macros across many forms but i do not know the syntax that would allow me to do so. For example, I have a macro that uses setvalue to change the value of a field if another field's value changes. The form field reference is [Forms]![f_events_and_shows_ds]![f_bookings_all].[Form]![entered_date_time]. I would like to invoke the same event in two forms but at present, i have to create (and maintain) two versions of the macro. Can you tell me what the syntax is that would allow me to replace the form name with the current form name (say) and is there somewhere that i could go on the web that would help me reference this area. |
#3
|
|||
|
|||
Referencing forms and fields
So there is nothing like a "currentform", "currentfield" argument available
that I could use "Arvin Meyer [MVP]" wrote: I think that you'll need to do this in code, where you can use a form name as an argument: Public Function DoSomething(frm As Form) If you put the function in a standard module, you can use it just like a macro, by setting the AfterUpdate event like: = DoSomething([Forms]![ThisForm]) -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "Daniel Jacobs" wrote in message ... I would like to reuse macros across many forms but i do not know the syntax that would allow me to do so. For example, I have a macro that uses setvalue to change the value of a field if another field's value changes. The form field reference is [Forms]![f_events_and_shows_ds]![f_bookings_all].[Form]![entered_date_time]. I would like to invoke the same event in two forms but at present, i have to create (and maintain) two versions of the macro. Can you tell me what the syntax is that would allow me to replace the form name with the current form name (say) and is there somewhere that i could go on the web that would help me reference this area. . |
#4
|
|||
|
|||
Referencing forms and fields
Sure, you could use:
Screen.ActiveForm and Screen.ActiveControl but that can be dangerous if something else gains focus. -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "Daniel Jacobs" wrote in message ... So there is nothing like a "currentform", "currentfield" argument available that I could use "Arvin Meyer [MVP]" wrote: I think that you'll need to do this in code, where you can use a form name as an argument: Public Function DoSomething(frm As Form) If you put the function in a standard module, you can use it just like a macro, by setting the AfterUpdate event like: = DoSomething([Forms]![ThisForm]) -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "Daniel Jacobs" wrote in message ... I would like to reuse macros across many forms but i do not know the syntax that would allow me to do so. For example, I have a macro that uses setvalue to change the value of a field if another field's value changes. The form field reference is [Forms]![f_events_and_shows_ds]![f_bookings_all].[Form]![entered_date_time]. I would like to invoke the same event in two forms but at present, i have to create (and maintain) two versions of the macro. Can you tell me what the syntax is that would allow me to replace the form name with the current form name (say) and is there somewhere that i could go on the web that would help me reference this area. . |
#5
|
|||
|
|||
Referencing forms and fields
Perfect. Thank you.
"Arvin Meyer [MVP]" wrote: Sure, you could use: Screen.ActiveForm and Screen.ActiveControl but that can be dangerous if something else gains focus. -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "Daniel Jacobs" wrote in message ... So there is nothing like a "currentform", "currentfield" argument available that I could use "Arvin Meyer [MVP]" wrote: I think that you'll need to do this in code, where you can use a form name as an argument: Public Function DoSomething(frm As Form) If you put the function in a standard module, you can use it just like a macro, by setting the AfterUpdate event like: = DoSomething([Forms]![ThisForm]) -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.mvps.org/access http://www.accessmvp.com "Daniel Jacobs" wrote in message ... I would like to reuse macros across many forms but i do not know the syntax that would allow me to do so. For example, I have a macro that uses setvalue to change the value of a field if another field's value changes. The form field reference is [Forms]![f_events_and_shows_ds]![f_bookings_all].[Form]![entered_date_time]. I would like to invoke the same event in two forms but at present, i have to create (and maintain) two versions of the macro. Can you tell me what the syntax is that would allow me to replace the form name with the current form name (say) and is there somewhere that i could go on the web that would help me reference this area. . . |
Thread Tools | |
Display Modes | |
|
|