473,320 Members | 1,883 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

combo boxes inconsistant behaviror using selStart

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
5 2717
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
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

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
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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Newsgroup | last post by:
I have a multiline textbox with 10 lines of text in it. I want to search Line by Line for the word" ". How do I process one line in a text box at a time? I DON'T want to just search the whole...
1
by: FZ | last post by:
Hi Gang, I was wondering if a generous person might be able to walk me through what I believe is a pretty simple task. I actually have significant Access experience, but I haven't done it in...
3
by: Bob Alston | last post by:
I am using a combo box to select the key to records and then go to the selected record on my form. Works well. However, the list, which contains people names, is rather long. What I would like...
5
by: jjyconsulting | last post by:
Newbie needing some help. I have a tblParticipants. The fields include gender, education_level, income, occupation etc., I'm trying to create a form where a user can run a query from the form and...
6
by: Dave | last post by:
I want to put the information that the user selects in my combo boxes into a subform that lies on the same form as the combo boxes. Thanks for your help already, Dave
1
by: Dave | last post by:
Hello all, First I'd like to apologize...This post was meant to be put in my previous post, but I tried many times without success to reply within my previous post. Now here goes... I have a...
2
by: Dave | last post by:
I have 3 tables of information feeding into 4 combo boxes on my main form (DR Form). I have as many list boxes (acting as text boxes) as there are fields in each one of the 3 tables. Once...
9
by: prakashwadhwani | last post by:
I have an unbound combo box in the form header. I have used an input mask "CCCC" 40 times to limit the max number of characters to 40. When I tab into the combo box & press a character say "K"...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.