By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,316 Members | 2,132 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,316 IT Pros & Developers. It's quick & easy.

combo boxes inconsistant behaviror using selStart

P: n/a
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

Jan 21 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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

Jan 21 '07 #2

P: n/a
CD********@FortuneJames.com wrote:
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.
One more thing. Look at help for the Input Mask Property's ability to
store either the literal string or the input string. That might give
you another option.

James A. Fortune
CD********@FortuneJames.com

Jan 21 '07 #3

P: n/a

Thanks so much for your quick response. I agree now that I should have
stored the ssn without the dashes. And I will use the code you have
provided for fixing that issue. However I had two combos that didn't
work and the other one had no input mask. I did check and there are no
spaces in the data. But I did take another look at what is different
between the one that works and the two that don't. They each have
their own query, but the two that don't work are using a field besides
the primary key to find a record based on the selection in the combo
box. There could be multiple answers but we are fine with finding the
first one.....Any ho....I added the primary key to the non-working
combos and made it the bound field....and now the combos work.

I don't understand why they work....what would it matter which field we
search on...why now does matter to the selstart = 0 in the got focus of
the combo.

Again don't know why it works, would love to understand it, but thought
it might help someone else....
and why after all this time, and finally posting do I get it figured
out.

Thanks again, as I will use the code you provided, and I'm sure others
will, too. I'm always finding some piece of code to use in some older
postings.

Deb

Jan 21 '07 #4

P: n/a
debbie wrote:
Thanks so much for your quick response. I agree now that I should have
stored the ssn without the dashes. And I will use the code you have
provided for fixing that issue. However I had two combos that didn't
work and the other one had no input mask. I did check and there are no
spaces in the data. But I did take another look at what is different
between the one that works and the two that don't. They each have
their own query, but the two that don't work are using a field besides
the primary key to find a record based on the selection in the combo
box. There could be multiple answers but we are fine with finding the
first one.....Any ho....I added the primary key to the non-working
combos and made it the bound field....and now the combos work.
I'm glad you have them working. Be sure to include WHERE fieldname IS
NOT NULL in your combobox queries. Nulls in the return set can
interfere with the combobox's Auto Expand functionality. I think this
is because of the way Access tests for equality to Null values.
>
I don't understand why they work....what would it matter which field we
search on...why now does matter to the selstart = 0 in the got focus of
the combo.
I can't tell from my vantage point why the search field changes things.
I think SelStart = 0 works because comboboxes seem to treat Input Masks
almost as part of the value even when you make it clear that they're
not to be taken literally. Without the Input Mask I don't see how
you're getting an initial space. Is it possible that your query based
on existing form values somehow puts an unintentional space into an
expression?
>
Again don't know why it works, would love to understand it, but thought
it might help someone else....
and why after all this time, and finally posting do I get it figured
out.
People figure out answers when they post because it puts irony on their
side :-).
>
Thanks again, as I will use the code you provided, and I'm sure others
will, too. I'm always finding some piece of code to use in some older
postings.
Not all the information I post is so great, but I have my moments. I'm
thinking of saving every post I make because some old posts of mine
seem to be dropping off and I have no control over how long posts get
saved.
>
Deb
James A. Fortune
CD********@FortuneJames.com

Jan 21 '07 #5

P: n/a
"debbie" <de****@seaportnet.comwrote in message
<11**********************@m58g2000cwm.googlegroups .com>:
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
For selstart to occur when clicking on the control, did you also try
setting .SelStart = 0 in the On Mouse Up event of the control?

--
Roy-Vidar
Jan 21 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.