Avatar

Level 3

Hi,

I have a procedure that I want to do every time someon exits any of my many text boxes in a form.  Basically, I want the computer to check to see if there are any spaces at the beginning of the entry, and if so, to remove them.

To do that, I wrote a Right() and Left() function, and I want to write another function SpaceTrim() that uses those Right and Left functions to accomplish this.  In general, SpaceTrim() should look something like this:

function

SpaceClear(MyField){

while (left(MyField.rawValue,1) == ' '){

MyField.rawValue

= right(MyField.rawValue,MyField.length - 1);

}

I tried calling this function as SpaceClear(FieldName) and SpaceClear(FieldName.name), and neither would work.  (I didn't really expect that to work, but thought it was worth a try.)

If you want a function to operate on some object that you can specify as an argument to the function, how do you do that?  I'm hoping there's something a little more elegant than changing the object name into a string, passing that string, and then using the eval() command.  But maybe not.

Thanks!

Emily