debbie wrote:
I have three combo boxes on a subform. I have tried setting them up so
that when the user clicks in the combo box the curser moves to the
left. I have searched the posts and can find nothing that answers my
problem....no matter what I have tried....on click, set focus, got
focus...one combo box works and the other two start one space from the
left....now if the user tabs, of course they all work...and if you've
clicked anywhere else on the sub form they all work...BUT when you
first open the form or if you refresh, then the same two don't work.
One of the none working combo boxes is social security number, which
has an input mask, but in the underlying query I have now created a
field from ssn and that field does not have an input mask...still won't
work. As far as I can see and I've done a lot of looking, the
properties on the boxes are the same.... am I blind and can't see
what's different. I have spent several hours on several occasions on
trying to fix this. Oh by the way it's Access 2002.
I'm sure hoping the gurus around here have a clue...I hate to tell my
boss I can't find the problem.
Thanks for your time and attention.
Debbie
I think that your input mask is causing the problem. Is the input mask
placing an initial space into the table? One way to solve this is to
remove the input mask on SSN and filter out any nondigits that get
entered when saving it to the table. You can always format the SSN
when you need to display it. I also think that your idea of using
SelStart to get the behavior the way you want when using an input mask
is correct. See:
http://groups.google.com/group/micro...b8f5b992c1b5d4
To filter out the nondigits you can adapt the following module function
to your needs:
Public Function Printable(varIn As Variant) As String
Dim strTemp As String
Dim strChar As String
Dim lngI As Long
Dim lngLen As Long
Printable = ""
If IsNull(varIn) Then Exit Function
If varIn = "" Then Exit Function
lngLen = Len(varIn)
strTemp = ""
For lngI = 1 To lngLen
strChar = Mid(varIn, lngI, 1)
If Asc(strChar) <= 126 And Asc(strChar) >= 32 Then
strTemp = strTemp & strChar
End If
Next lngI
Printable = strTemp
End Function
Note that the digits 0 through 9 are the ASCII values 48 through 57.
Since I'm already at this point (untested):
Public Function DigitsOnly(varIn As Variant) As Variant
Dim strTemp As String
Dim strChar As String
Dim lngI As Long
Dim lngLen As Long
DigitsOnly = Null
If IsNull(varIn) Then Exit Function
DigitsOnly = ""
If varIn = "" Then Exit Function
lngLen = Len(varIn)
strTemp = ""
For lngI = 1 To lngLen
strChar = Mid(varIn, lngI, 1)
If Asc(strChar) >= 48 And Asc(strChar) <= 57 Then
strTemp = strTemp & strChar
End If
Next lngI
DigitsOnly = strTemp
End Function
Then your update query will look something like (with MyTable replaced
by your table name):
UPDATE MyTable SET SSN = DigitsOnly(SSN);
If you are using a bound form and need to see the formatting, you may
have to live with the input mask or have a separate unbound textbox
that controls a hidden bound textbox. Note that to do this you'd also
need to fill the unbound textbox in the form's On Current event and
update the bound textbox in the unbound textbox's AfterUpdate event,
using DigitsOnly to place the formatted unbound textbox's value into
the bound textbox as an unformatted string. Perhaps commit the change
in the same AfterUpdate event. The hidden bound textbox should not
have an input mask. Hopefully, some of these ideas will help you find
a solution.
James A. Fortune
CD********@FortuneJames.com