Tab verses mouse

  • Thread starter Thread starter Rick Patterson
  • Start date Start date
R

Rick Patterson

I have a form I've developed with a drop-down combo box in one of the
fields. Attached to the combo box selections are adjustments to the
apearence of the form. For instance if selection is number 1 certain fields
in the form are visable but if selection is number 2 then other fields are
visible instead.
The problem:
If I select one of the options with the mouse the code is carried out fine
but if I tab to the box and type in 2 or 1 and tab to the next field the
code does not recognize the entry.
Any suggestions to remedy would be appreciated, I am very much a newby!!

Rick Patterson
(e-mail address removed)
 
Rick Patterson said:
I have a form I've developed with a drop-down combo box in one of the
fields. Attached to the combo box selections are adjustments to the
apearence of the form. For instance if selection is number 1 certain
fields in the form are visable but if selection is number 2 then
other fields are visible instead.
The problem:
If I select one of the options with the mouse the code is carried out
fine but if I tab to the box and type in 2 or 1 and tab to the next
field the code does not recognize the entry.
Any suggestions to remedy would be appreciated, I am very much a
newby!!

What event of the combo box control are you using to run your code?
Would you care to post the code?
 
Thanks Dirk,
Here is the code.

Private Sub DispatchType_Change()

If DispatchType.Value = 6 Then
NumberOfTasksSold.Visible = False
BillableHrsSold.Visible = False
DiscountsorCoupons.Visible = False
TotalFRSold.Visible = False
TMHoursBilled.Visible = True
TotalTMSold.Visible = True
Job_Detail_and_Spiffs_subform.Visible = True

ElseIf DispatchType.Value = 3 Then
NumberOfTasksSold.Visible = False
BillableHrsSold.Visible = False
DiscountsorCoupons.Visible = False
TotalFRSold.Visible = False
TMHoursBilled.Visible = True
TotalTMSold.Visible = True
Job_Detail_and_Spiffs_subform.Visible = True

ElseIf DispatchType.Value = 7 Then
NumberOfTasksSold.Visible = False
BillableHrsSold.Visible = False
DiscountsorCoupons.Visible = False
TotalFRSold.Visible = False
TMHoursBilled.Visible = False
TotalTMSold.Visible = False
WorkOrderNumber.Visible = False
Job_Detail_and_Spiffs_subform.Visible = False

ElseIf DispatchType.Value = 8 Then
NumberOfTasksSold.Visible = False
BillableHrsSold.Visible = False
DiscountsorCoupons.Visible = False
TotalFRSold.Visible = False
TMHoursBilled.Visible = False
TotalTMSold.Visible = False
WorkOrderNumber.Visible = False
Job_Detail_and_Spiffs_subform.Visible = False

ElseIf DispatchType.Value = 2 Then
NumberOfTasksSold.Visible = False
BillableHrsSold.Visible = False
DiscountsorCoupons.Visible = False
TotalFRSold.Visible = False
TMHoursBilled.Visible = False
TotalTMSold.Visible = False
Job_Detail_and_Spiffs_subform.Visible = True

Else
NumberOfTasksSold.Visible = True
BillableHrsSold.Visible = True
DiscountsorCoupons.Visible = True
TotalFRSold.Visible = True
TMHoursBilled.Visible = False
TotalTMSold.Visible = False
Job_Detail_and_Spiffs_subform.Visible = True

End If

End Sub
 
"My appologies,

This is the correct code that I am using I updated it since the previous
post. When selecting the choices from the drop-down "dispatchtype" with the
mouse the code is carried out. However, if I make a choice by tabbing to
the dispatchType" drop-down and then tabbing to the next field the code is
not carried out. Is there any way to get the code to run if using the tab
key. This would speed up data entry into the form considerably.

Private Sub DispatchType_Change()

If DispatchType.Value = 6 Then
NumberOfTasksSold.Visible = False
BillableHrsSold.Visible = False
DiscountsorCoupons.Visible = False
TotalFRSold.Visible = False
TMHoursBilled.Visible = True
TotalTMSold.Visible = True
WorkOrderNumber.Visible = True
Job_Detail_and_Spiffs_subform.Visible = True

ElseIf DispatchType.Value = 3 Then
NumberOfTasksSold.Visible = False
BillableHrsSold.Visible = False
DiscountsorCoupons.Visible = False
TotalFRSold.Visible = False
TMHoursBilled.Visible = True
TotalTMSold.Visible = True
WorkOrderNumber.Visible = True
Job_Detail_and_Spiffs_subform.Visible = True

ElseIf DispatchType.Value = 7 Then
NumberOfTasksSold.Visible = False
BillableHrsSold.Visible = False
DiscountsorCoupons.Visible = False
TotalFRSold.Visible = False
TMHoursBilled.Visible = False
TotalTMSold.Visible = False
WorkOrderNumber.Visible = False
Job_Detail_and_Spiffs_subform.Visible = False

ElseIf DispatchType.Value = 8 Then
NumberOfTasksSold.Visible = False
BillableHrsSold.Visible = False
DiscountsorCoupons.Visible = False
TotalFRSold.Visible = False
TMHoursBilled.Visible = False
TotalTMSold.Visible = False
WorkOrderNumber.Visible = False
Job_Detail_and_Spiffs_subform.Visible = False

ElseIf DispatchType.Value = 2 Then
NumberOfTasksSold.Visible = False
BillableHrsSold.Visible = False
DiscountsorCoupons.Visible = False
TotalFRSold.Visible = False
TMHoursBilled.Visible = False
TotalTMSold.Visible = False
WorkOrderNumber.Visible = False
Job_Detail_and_Spiffs_subform.Visible = False

Else
NumberOfTasksSold.Visible = True
BillableHrsSold.Visible = True
DiscountsorCoupons.Visible = True
TotalFRSold.Visible = True
TMHoursBilled.Visible = False
TotalTMSold.Visible = False
WorkOrderNumber.Visible = True
Job_Detail_and_Spiffs_subform.Visible = True

End If

End Sub

Thanks for any suggestions or comments.
Rick Patterson
 
Rick Patterson said:
"My appologies,

This is the correct code that I am using I updated it since the
previous post. When selecting the choices from the drop-down
"dispatchtype" with the mouse the code is carried out. However, if I
make a choice by tabbing to the dispatchType" drop-down and then
tabbing to the next field the code is not carried out. Is there any
way to get the code to run if using the tab key. This would speed up
data entry into the form considerably.

Private Sub DispatchType_Change()

If DispatchType.Value = 6 Then
NumberOfTasksSold.Visible = False
BillableHrsSold.Visible = False
DiscountsorCoupons.Visible = False
TotalFRSold.Visible = False
TMHoursBilled.Visible = True
TotalTMSold.Visible = True
WorkOrderNumber.Visible = True
Job_Detail_and_Spiffs_subform.Visible = True

ElseIf DispatchType.Value = 3 Then
NumberOfTasksSold.Visible = False
BillableHrsSold.Visible = False
DiscountsorCoupons.Visible = False
TotalFRSold.Visible = False
TMHoursBilled.Visible = True
TotalTMSold.Visible = True
WorkOrderNumber.Visible = True
Job_Detail_and_Spiffs_subform.Visible = True

ElseIf DispatchType.Value = 7 Then
NumberOfTasksSold.Visible = False
BillableHrsSold.Visible = False
DiscountsorCoupons.Visible = False
TotalFRSold.Visible = False
TMHoursBilled.Visible = False
TotalTMSold.Visible = False
WorkOrderNumber.Visible = False
Job_Detail_and_Spiffs_subform.Visible = False

ElseIf DispatchType.Value = 8 Then
NumberOfTasksSold.Visible = False
BillableHrsSold.Visible = False
DiscountsorCoupons.Visible = False
TotalFRSold.Visible = False
TMHoursBilled.Visible = False
TotalTMSold.Visible = False
WorkOrderNumber.Visible = False
Job_Detail_and_Spiffs_subform.Visible = False

ElseIf DispatchType.Value = 2 Then
NumberOfTasksSold.Visible = False
BillableHrsSold.Visible = False
DiscountsorCoupons.Visible = False
TotalFRSold.Visible = False
TMHoursBilled.Visible = False
TotalTMSold.Visible = False
WorkOrderNumber.Visible = False
Job_Detail_and_Spiffs_subform.Visible = False

Else
NumberOfTasksSold.Visible = True
BillableHrsSold.Visible = True
DiscountsorCoupons.Visible = True
TotalFRSold.Visible = True
TMHoursBilled.Visible = False
TotalTMSold.Visible = False
WorkOrderNumber.Visible = True
Job_Detail_and_Spiffs_subform.Visible = True

End If

End Sub

Thanks for any suggestions or comments.
Rick Patterson

There's something in your description that I don't follow. You say, "if
I make a choice by tabbing to the dispatchType drop-down and then
tabbing to the next field ..." -- but how does this constitute making a
choice? If you merely tab into and then out of the combo box, you
haven't changed the value of the control in any way, and so the Change
event won't fire. Does this control, or its bound field, have a default
value that you are thus accepting? That still won't fire the Change
event (nor the AfterUpdate event, which would be better to use anyway).
The Change event will only fire if you either type a value in the
control or use the mouse to select a value from its dropdown list.
 
Thanks for the reply,
When filling out the form and completing the entry information into the
previous field (prior to the "dispatchType" drop-down field) I want to TAB
to the next field , which is DispatchType Drop-Down and type the number of
the choice I want to make (ie:6, 7, or 3) rather than selecting the drop
down and choice with the mouse. Once I enter the choice in the field I want
to TAB to the next field. The problem is the code is not recognized unless
I actually make the selection with the mouse.
I hope this is clearer.
Thanks again
Rick
 
Thank You Dirk,
You answered my question!!!
The answere is to use "AfterUpdate" That works great.
Thanks for your input.
Rick Patterson
 
Rick Patterson said:
Thank You Dirk,
You answered my question!!!
The answere is to use "AfterUpdate" That works great.
Thanks for your input.

Gosh, I'm good! <lol> Actually, I hadn't noticed the details of your
code, but yes, I can see why it makes a difference. When you type in a
combo box, the Change event fires each time the displayed text
changes -- essentially for each keystroke -- but *before* the Value
property is updated. When you select with the mouse, on the other hand,
the Value is updated first, and *then* the Change event is fired once
because the text has changed. Your code was firing for each keystroke,
but testing the Value of the combo box, which hadn't been changed yet.

For most purposes, it's better to use the AfterUpdate event, which only
fires once, after the value has been changed, regardless of what means
is used to change it. The Change event of combo and text boxes should
only be used when you want to react to incremental changes to the text
in the control (which you can get from the Text property), and not to
the final value.
 
Back
Top