I am writing an order receiving application in Access 2000. In this app you type in the tanker number the app looks that up in a table and should return just one row. The code below is showing how I am handling the errors of more than one row returned or no rows returned. After an error is handled I would like the focus to be returned to my tanker_txtbx so that the user can enter a new tanker number, but for some reason the application simply goes to the next box in the tab order. I have tried setting the focus to some other text boxes in the form and it goes to them, it just won't go to the one text box that I want it to go to. The code is listed below:
Any insight to the SetFocus command would be helpful. Thanks.
Jeff
Code:
If rstTanker.RecordCount > 1 Then
'More than one record
MsgBox "Multiple records found with tanker number " & tanker_txtbx.Value & ". Unable to process automatically"
tanker_txtbx.Value = Null
tanker_txtbx.SetFocus
rstTanker.Close
ElseIf rstTanker.RecordCount < 1 Then
'No records returned because tanker # is not instransit
MsgBox "No record found for tanker number " & tanker_txtbx.Value & ". Make sure you entered it correctly"
tanker_txtbx.Value = Null
tanker_txtbx.SetFocus
rstTanker.Close
Else
'set textboxes to cursor values
lbs_per_berk_txtbx = rstTanker("LBS_PER_BERK")
ship_date_txtbx = rstTanker("SHIP_DATE")
snf_pct_per_berk_txtbx = rstTanker("SNF_PCT_PER_BERK")
bf_pct_per_berk_txtbx = rstTanker("BF_PCT_PER_BERK")
End If
Any insight to the SetFocus command would be helpful. Thanks.
Jeff
Comment