Kaup, Chester
Chester_Kaup at kindermorgan.com
Tue Feb 11 08:20:55 CST 2014
I have a form with two text boxes and a combo box. I use the following code to display a value in the combo box when the form opens. The code then shifts the focus to the first text box. I have code attached to the combo. It runs fine if I select something from the drop down list but does not run if I click on the default value that is displayed in the combo box. If I select another item in the drop down list and then go back and select the default value displayed the code then runs. I think the problem has to do with selecting something from the combo box list but I am unsure how to proceed. Thanks.
Form opening code
Private Sub Form_Open(Cancel As Integer)
Me.WellNumber.SetFocus
Me.WellNumber.ListIndex = 0
Me.StartDate.SetFocus
End Sub
Combo box code
Private Sub WellNumber_Click()
Dim frm As Form, ctl As Control
Dim varItm As Variant, X As Variant
Set frm = [Forms]![frm Set Down Report Options]
Set ctl = frm!WellNumber
DoCmd.SetWarnings Off
'get the row number of the selected row in the list box
varItm = ctl.ListIndex
Select Case varItm
Case 0 'all wells
DoCmd.OpenReport "rpt Set Down All", acViewReport
Case Else
DoCmd.OpenReport "rpt Set Down in a Time Interval", acViewReport
End Select
'Stop
End Sub