Another module newbie needs some help passing variables

eaglewingmd

New member
Local time
Yesterday, 20:27
Joined
Jun 4, 2010
Messages
2
O.K. I have always had a problem conceptualizing scope and modules and variables and public and private. It’s like a mind road block.

I have a form that entries are made in text box controls. Below is the code and it works in the form on an AfterUpdate event.

I am finding that I need this code a few other places on the form so I thought I would just make it a module. So I put it in a subroutine in a module, then called it. And voila, nothing happens.

Do I need to declare variables in the module? If so then how do I get the information back into the text box controls on the form after the call? If that’s the case, why can’t I just use the variables from the form?

Thanks for any help and direction.

If gen = "M" Then
If WR <= MSW2 Then
fr = "Small"
low = MS1
high = MS2
ElseIf WR > MLW2 Then
fr = "Questionable"
low = MM1
high = MM2
ElseIf WR > MLW1 Then
fr = "Large"
low = ML1
high = ML2
Else
fr = "Medium"
low = MM1
high = MM2
End If
End If
 
Thanks for the advice. I had looked there, and I had thought I was coding correctly. I just reviewed it again and I think I'm doing it right. This is the latest attempt

Public Sub mupdate()
Dim gen As String
Dim wr As Double
Dim fr As String
Dim low As Double
Dim high As Double

gen = sx '(sx is a text control format as a general number)
wr = WRI '(WRI is a text control format as a general number)

If gen = "M" Then
If wr <= MSW2 Then '(MSW2 is a text control format as a general number)
frm = "Small"
lw = MS1 '(MS1 is a text control format as a general number)
hi = MS2 '(MS2 is a text control format as a general number)
ElseIf wr > MLW2 Then
frm = "Questionable"
lw = MM1
hi = MM2
ElseIf wr > MLW1 Then
frm = "Large"
lw = ML1
hi = ML2
Else
frm = "Medium"
lw = MM1
hi = MM2
End If
End If

fr = frm '(fr is a text control format as a general number)
low = lw '(low is a text control format as a general number)
high = hi '(high is a text control format as a general number)

End Sub
 

Users who are viewing this thread

Back
Top Bottom