Modules

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have about 10 forms that use the same routine. I would like to put it into
a module so I could just us a call command instead of having it in every
form. I've made the module but the problem I have is I use the me.recalc
command when the routine is in the form but when I try and use that in the
module I get a compile error: Invalid use of Me keyword. Is there anyway to
recalc the form that calls the module. I use the recalc to be sure that all
the calculations in the form are updated.
thanks for any help.
 
CD Tom formulated on dinsdag :
I have about 10 forms that use the same routine. I would like to put it into
a module so I could just us a call command instead of having it in every
form. I've made the module but the problem I have is I use the me.recalc
command when the routine is in the form but when I try and use that in the
module I get a compile error: Invalid use of Me keyword. Is there anyway to
recalc the form that calls the module. I use the recalc to be sure that all
the calculations in the form are updated.
thanks for any help.

call the recalc in the VBA code of the form after calling the module
instead of within the module
or pass the calling form's name as a parameter of the module
and use that name instead of ME

grtz
 
If multiple forms can use the same sub or function and the sub or function
has to know the name of the form, pass the form as an argument:

Call ReCalc(Me as Form)

Then

Public Sub ReCalc(frm AS Form)

If frm!...
 
When I use the Call ReCalc(Me as Form) I get a compile error: Expected: list
separator or ) can't seem to pass the form name.
 
Klatuu,
If I leave out the as form and just use the (Me) then I don't get a compile
error. I get an object required when I use the frm.recalc in the module.
What code should I use to do the recalc. Thanks
 
Howdy, partner!
Here is an example of how I use this concept:

'---------------------------------------------------------------------------------------
' Procedure : SetNavButtons
' DateTime : 2/6/2006 09:36
' Author : Dave Hargis
' Purpose : Enables and Disables Nav buttons based on current record
position
'---------------------------------------------------------------------------------------
'
Sub SetNavButtons(ByRef frmSomeForm As Form)

On Error GoTo SetNavButtons_Error

With frmSomeForm
If .CurrentRecord = 1 Then
.cmdNextRec.Enabled = True
.cmdLastRec.Enabled = True
.cmdNextRec.SetFocus
.cmdFirstRec.Enabled = False
.cmdPreviousRec.Enabled = False
ElseIf .CurrentRecord = .Recordset.RecordCount Then
.cmdFirstRec.Enabled = True
.cmdPreviousRec.Enabled = True
.cmdPreviousRec.SetFocus
.cmdNextRec.Enabled = False
.cmdLastRec.Enabled = False
Else
.cmdFirstRec.Enabled = True
.cmdPreviousRec.Enabled = True
.cmdNextRec.Enabled = True
.cmdLastRec.Enabled = True
End If
End With
 
I've been playing around with this as have figured it out. Thanks for all
you help. Are you still playing cowboy and doing and shooting?

CD
 
This is North Texas.
It is August.
So far 17 days > 100.
The range is not air conditioned. ( my guns and I are until Sep, Oct,
depending)
 
Thanks for all your help. Hopefully some day we'll be able to shoot together
again.

CD
 
Back
Top