On my main form I have a combobox with logic in the afterupdate event to add a record to a table. That table is the source for a subform.
Here's what I'm doing in the afterupdate event:
1. Append a record to TableA.
2. Requery the subform (which is a list of TableA).
3. Set focus to a specific control of the new record (always the last record) in the subform.
The first two steps work perfectly, but I'm having a problem with getting the focus set. No error message, but it doesn't work. The focus remains in the combobox.
Here's my code, which is at the very end of the combobox update event, after the requery:
With Me.mySubform
.Form.Recordset.MoveFirst
For i = 0 To .Form.Recordset.RecordCount - 1
If intI = .Form.Recordset.RecordCount - 1 Then
.Form.Controls("QuantityReceived").SetFocus
Exit For
End If
.Form.Recordset.MoveNext
Next i
End With
Am hoping someone can tell me what I've overlooked.
Here's what I'm doing in the afterupdate event:
1. Append a record to TableA.
2. Requery the subform (which is a list of TableA).
3. Set focus to a specific control of the new record (always the last record) in the subform.
The first two steps work perfectly, but I'm having a problem with getting the focus set. No error message, but it doesn't work. The focus remains in the combobox.
Here's my code, which is at the very end of the combobox update event, after the requery:
With Me.mySubform
.Form.Recordset.MoveFirst
For i = 0 To .Form.Recordset.RecordCount - 1
If intI = .Form.Recordset.RecordCount - 1 Then
.Form.Controls("QuantityReceived").SetFocus
Exit For
End If
.Form.Recordset.MoveNext
Next i
End With
Am hoping someone can tell me what I've overlooked.