Full Version: Tabbing Into Control And Selecting Data
UtterAccess Forums > Microsoft® Access > Access Forms
ehops
I have a combo box with a list of valid defect codes in tab order after a textbox where the user enters number of defects. If the # defects < 7 the focus skips the defect codes combo box. If > 7, focus is set to combo box. Since I haven't been able to figure out how to have a blank value as valid in the combo box, I have set the default to "NA". When focus goes to the combo box, I would like the data to be 'selected' so the user can simply type a new value to overwrite the last one (quicker, simpler data entry). Please help me understand how this can be done.
Thanks a bunch!
theDBguy
Hi,
Is the bound field for the combobox set as "required?" If not, then the combobox should be fine when left as blank.
In the Focus event of the combobox, you could try something like:
Me.ComboboxName.SelStart = 0
Me.ComboboxName.SelLength = Len(Me.ComboboxName)
Just my 2 cents... 2cents.gif
PS. Please note that the above code assumes that the combobox is bound to the first visible column. Please let us know if that is not the case.
ehops
Hi dBGuy!!
Thanks for the quick response. The simple code for selecting the data upon entry worked great. Thanks!!
Not sure what you mean about about the bound field of the combo box being required. The field in the table is not required. The combo box control on the form is set to the first column (as desired), but I don't see anywhere that would make it required.
Apologies for being a noob.
theDBguy
Hi,
If the combobox is not required to have any value, then leaving it blank should be fine. I'm not sure why you need to have "NA" in it as a default. What happens if you just leave it blank?
ehops
Blank is not an option since the combo box references a table. I was not able to enter a blank record into the table (both fields set to required = yes and allow zero length as no). I set the combo box control data property settings to "limit to list" = yes, "alow edits" = no. I don't want the user to enter and defect reasons not in the DEFECTS table. DEFECTS table just has DefectCd (char*2) and DefectDesc (char*40).
Thanks for your thoughts!
theDBguy
Hi,
This is the part where because I don't see what you're seeing that it's a little harder to get on the same page as you. So, for example, your form is probably based on some table where one of the field is the "defects code," correct? And, the defects code is selected from a combobox where the choices come from another table where the defect code and description are stored, correct? If so, then what I am saying is that the field on your form for the defect code shouldn't care if you leave it blank as long as that field is not required.
For example, let's say we are entering a new record. So, we fill out the other fields but when we get to the defects combobox, we should be able to skip it and save the record with a blank combobox, correct?
Just my 2 cents... 2cents.gif
ehops
HA!! You're right.
My trouble shooting must have evolved and I have previous attempts at fixing the problem that are no longer needed.
I am learning so much about how all this works together. A good thing and bad thing, right? I am pretty deep into it now really wishing I could start over and set up my foundation a little differently. Oh well!!
You guys are all a great help. Thanks!
---eric
theDBguy
Hi eric,
Glad to hear you're all sorted now. We are always happy to help.
Good luck with your project.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.