Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Annie Russell   on Dec 29 In MS Office Category.

  
Question Answered By: Meenakshi Khochar   on Dec 29

ByRef is the default anyway. The opposite is ByVal. If you want the subroutine
to change things back in the caller's area, you need ByRef because ByVal takes a
private copy for the subroutine.

Showing ByRef explicitly - even though it is the default - is good programming
practice.

A global private control (yes I agree - very clumsy wording, sorry) was meant to
say, put a

Private mField As Control

at the top of your module, before any subroutines or functions, but after your

Option Explicit

It declares a Control variable of this name that is private to the module, but
available (global) to all the code  inside the module. The lower-case "m" at the
start of the name is a historical way of prefixing such module-wide variables
(it started with object-oriented programming, but is a useful convention).

Hutch's solution is along the same lines as mine - having the Object or Control
variable and getting the OK click  to put the value back there. What I've done
is to encapsulate all of this inside the module, so that you only need a single
line to call  it from wherever you need it.

I discourage the use of global variables, and particularly of having the code
"force feed" information into service modules. I much prefer to supply the
information to the service module inside its own calling sequence, and then let
it do what it needs to do, privately.

Share: 

 

This Question has 4 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Reference form values dynamically from another form? Or get search suggestion and latest updates.


Tagged: