Use VBa to change tab order is enter comments

robbie_1234

Registered User.
Local time
Today, 08:34
Joined
Jul 17, 2011
Messages
13
I have designed a form in Access 2010 to handle results of a survey.
The beginning of the form has a question if you are an adult or a youth. There are 2 adult possibilities; adults with combo box answers only to questions and no text comments (in this case the text box for comments that appears with each question is dimmed) and adults with combo box answers plus text comments to any or all of the questions. (in this case the text box for comments that appears with each question is highlighted)
If you are a youth, then the "adult" questions are dimmed. There are also 2 youth possibilities: youth with combox box answers only to questions (the text box for comments that appears with each question is dimmed) and no comments and youth with combox box answers plus comments to any or all of the questions (textbox for comments that appears with each question is highlighted).

I have set the form so the tab order follows the combox box responses only. If there are comments I have to mouse over to the text box, add the comments. If I tab, the tab moves me into the next questions text box, not the next questions combo box. I then have to mouse to the next question combo box.

I would like to set the form up so that in those adults and youth that comment on the combo box questions, when I hit tab it would move from (for example) question 1 text box to question 2 combo box rather than question 2 comment text box.

Form example:
Question 1 dropdown Combo box choices 1-5, 88 (did not participate), or 99 missing response; Text Box for comments
Question 2 dropdown Combox choices 1-5, 88, 99; Text box for comments.

Can anyone provide me suggestions?

I was, with your help, able to resolve some "if/then VBa code" to dim textboxes when a specific value was chosen in the Adult/Youth combo box at the start of the form.
 
Hi Robbie 1234
I would consider 3 options.
The first, is to manage the data via vba (as per you existing design)

The second, is to put your questions into another table, and have 1 field that identifies "Adult" or "Youth" - Then create a query that selects either the Adult/Youth questions, depending on the selection.

The third option is an extension of this idea. Create subforms (under navigation tabs).When the user select Adult, the Youth tab is disbaled via vba and the Adult tab is disabled when the user selects Youth. Then your code changes forcus to the relevant subform.

Now - coming back to option 1, have you tried. . . .

if me.fieldname.value = "Youth" then
me.YouthField.setfocus
else
me.Adultfield.setfocus
end if
 
My survey database has several tables: one for all questions and the second for all possible answers. I do have the adult/youth field coded so that only adult questions show when 0i chose adult and only youth questions show when I chose youth.

Since most of the surveys have combo box answers only, I set the tab order to go from one combo box to the next. If they choose to comment I must then get the mouse and move the cursor to the comment box and type the text. If I hit tab it doesn't move me to the next combo box but to the next comment. I'm trying to code the comment box so if there are comments, it will move me to the next combo box. Otherwise the tab order is fine.
 
So them the following concept should work if you attach it to the EXIT Field?
Just change the field names / conditions that apply to each field.

if me.fieldname.value = "Youth" then
me.YouthField.setfocus
else
me.Adultfield.setfocus
end if
 

Users who are viewing this thread

Back
Top Bottom