dixie
The function in the general module would be declared like this:
Public Function MyFunc(frm As Form)
Debug.Print frm![SomeControl]
End Function
That works just like:
Debug.Print Me.SomeControl
in the module of the form.
To call the function from your form's module:
Call MyFunc(Me)
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"dixie" <dix...@dogmail.com> wrote in message
news:UT%lc.125$UL2....@nnrp1.ozemail.com.au...
You could put a sub or function in the form's module, or write the
code in a module in such a way that you can pass the value of a
control to the function.
i.e.
Function myFunction(myControlValue)
The latter method is the way that I would do it, as I tend to need
these things in more than one form.
neil
"dixie" <dix...@dogmail.com> wrote in message news:<UT%lc.125$UL2....@nnrp1.ozemail.com.au>...
dixie,
Have you tried passing your controls as arguments to the methods in
you module?
-dp
p.s. If you're still having trouble, provide some sample code and I'd
be glad to help.
Here are a couple of module functions I use to keep users from typing
in more characters in the control than the table field is designed to
hold:
Public Function LimitField(KeyAscii As Integer, txtBox As TextBox,
intMax As Integer) As Integer
'If the field has reached its maximum then return 0
LimitField = KeyAscii
txtBox.SetFocus 'I forgot why I put this line here
If Len(txtBox.Text) = intMax Then
If KeyAscii <> 8 Then LimitField = 0
End If
End Function
Example call:
Private Sub txtCity_KeyPress(KeyAscii As Integer)
KeyAscii = LimitField(KeyAscii, txtCity, MaxAFieldWidth(iCity))
End Sub
Public Function LimitCombo(KeyAscii As Integer, cbxCombo As ComboBox,
intMax As Integer) As Integer
'If the field has reached its maximum then return 0
LimitCombo = KeyAscii
cbxCombo.SetFocus
If Len(cbxCombo.Text) = intMax Then
If KeyAscii <> 8 Then LimitCombo = 0
End If
End Function
Example call:
Private Sub cbxContact_KeyPress(KeyAscii As Integer)
KeyAscii = LimitCombo(KeyAscii, cbxContact, 50)
End Sub
The '8' is so that they're not in a cul-de-sac if they hit the limit.
I probably got the idea for these functions from code on this NG.
James A. Fortune