Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help creating a routine i can call

Status
Not open for further replies.

dbero

Technical User
Mar 31, 2005
109
US
Can someone please instruct me how to create a separate routine that I call from various places (cmd click) to go out and determine the length of text in form fields. What I am doing is i want to go determine the length of form fields several times within a routine, but don't want to continue to repeat the logic over and over. when I return from this routine, i want to return to the line just under where i was.

thank you,

Here are the functions i want to perform several times over.

If IsNull(Me.TxtStreet) Then StreetLen = 0 Else StreetLen = Len(Me.TxtStreet)
If IsNull(Me.TxtAdd1) Then Add1Len = 0 Else Add1Len = Len(Me.TxtAdd1)
If IsNull(Me.TxtPObox) Then POBoxLen = 0 Else POBoxLen = Len(Me.TxtPObox)
If IsNull(Me.TxtAdd2) Then Address2Len = 0 Else Address2Len = Len(Me.TxtAdd2)
If IsNull(Me.TxtSuite) Then SuiteLen = 0 Else SuiteLen = Len(Me.TxtSuite)




 
I think you can simply use the Len function (I believe for NULLS it returns zero).

How are you trying to use this code? Will you want it to run on any form change, change to certain fields, etc???



Ignorance of certain subjects is a great part of wisdom
 
Basically I just want to put the Len functions in a Module, then call the module from the cmd button and use the values determined from the module in the cmd routine.
 
Alex, Len(Null) returns Null (as expected ...)

dbero, you may consider Len(Trim(Me![control name] & ""))

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Actually, my question isn't on use of the len. It is how do I put that function in a module, then call it and return to the previous routine? thnk you
 
Gotcha. So, can you help by providing a sample of calling a module, from within a routine, then leaving the module returning to the line below that sent you there?
 
Again, what do you want to do with what ?
what have you tried so far and where in your code are you stuck ?
Do you know what a Function or a Sub are and how to deal with them ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top