A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Referencing forms and fields



 
 
Thread Tools Display Modes
  #1  
Old December 13th, 2009, 07:35 PM posted to microsoft.public.access.forms
Daniel Jacobs
external usenet poster
 
Posts: 19
Default 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  
Old December 13th, 2009, 10:22 PM posted to microsoft.public.access.forms
Arvin Meyer [MVP][_2_]
external usenet poster
 
Posts: 2,310
Default 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  
Old December 13th, 2009, 11:07 PM posted to microsoft.public.access.forms
Daniel Jacobs
external usenet poster
 
Posts: 19
Default 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  
Old December 14th, 2009, 04:55 PM posted to microsoft.public.access.forms
Arvin Meyer [MVP][_2_]
external usenet poster
 
Posts: 2,310
Default 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  
Old December 17th, 2009, 01:39 AM posted to microsoft.public.access.forms
Daniel Jacobs
external usenet poster
 
Posts: 19
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:13 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.