Pam said:
Dirk,
After entering the date in the first field, the report starts
printing and I like to tab to the next field, but have to press enter
to get the focus back to the whole form (the blue bar at top dims).
I'm not sure what you mean about the report displaying a dialog or
shifting focus. I'm not sure this explanation will help.
I'm not sure, but I *think* what's happening is normal -- the form
doesn't get the focus back until Access is done generating the report.
You could try modifying your code in an attempt to set the focus right
back to the form, like this:
'----- start of revised code -----
Private Sub Incoming_Exit(Cancel As Integer)
On Error GoTo Err_Incoming_Exit
Dim strReportName As String
If Me!CustomerName = "Lyondell" Then
strReportName = "rRMABatchRegularLyondell"
Else
strReportName = "rRMABatchRegular"
End If
DoCmd.OpenReport strReportName, _
WhereCondition:="JobNumber=" & Me!JobNumber
DoCmd.SelectObject acForm, Me.Name
Exit_Incoming_Exit:
Exit Sub
Err_Incoming_Exit:
MsgBox Err.Description
Resume Exit_Incoming_Exit
End Sub
'----- end of revised code -----
Note that I've assumed that the form name
"f*GeneralInformationWITHQUOTE" in your original code is the name of the
form on which this code is running. I used that assumption to simplify
the code somewhat, but if it's wrong, we'll have to go back to the full
"Forms!<form name>!<control name>" notation.
The "DoCmd.SelectObject" line in the above code is intended to get the
focus back onto this form as soon as possible; however, I have my
doubts as to whether it will work.
If it doesn't, I can think of two possible workarounds, but they are
both rather elaborate, and I'm not sure it's worth it. For my own
applications, I wouldn't normally use the Exit event of a text box to
open a report, as I feel that doesn't give the user a chance to correct
an incorrect entry. But if you really want the focus to get back to the
form immediately, and the above code revision doesn't do it, let me know
and we can try one of the alternatives I have in mind.