Greetings,
On a certain form, I have a text that a user can enter a code into. In the after_Update function for that box, the code entered is used in a query, of which, the result populates a name field for the code entered. If no name is returned by the query, then the code entered is invalid.
When an invalid code has been entered, so no name can be retrieved, I would like to alert the user with a message box, and set the focus back to the code field so the user can key in a corrected code.
There seems to be something about popping up the message box that prevents the focus from being set to the code text field.
How can I do this???
My code currently is as follows:
'do query:
'SELECT NAME
'FROM POOL_INFO
'WHERE POOL_INFO.CODE = Me.txtPoolCode.Value
If RS.RecordCount > 1 Then
Me.txtPoolName.Value = RS!NAME
Else
Me.txtPoolName.Value = ""
MsgBox ("A valid Pool Name could not be retrieved using the Pool Code entered. Please ensure that the Pool Code entered is correct."
Me.txtPoolCode.SetFocus
End If
Thank you,
Draug
On a certain form, I have a text that a user can enter a code into. In the after_Update function for that box, the code entered is used in a query, of which, the result populates a name field for the code entered. If no name is returned by the query, then the code entered is invalid.
When an invalid code has been entered, so no name can be retrieved, I would like to alert the user with a message box, and set the focus back to the code field so the user can key in a corrected code.
There seems to be something about popping up the message box that prevents the focus from being set to the code text field.
How can I do this???
My code currently is as follows:
'do query:
'SELECT NAME
'FROM POOL_INFO
'WHERE POOL_INFO.CODE = Me.txtPoolCode.Value
If RS.RecordCount > 1 Then
Me.txtPoolName.Value = RS!NAME
Else
Me.txtPoolName.Value = ""
MsgBox ("A valid Pool Name could not be retrieved using the Pool Code entered. Please ensure that the Pool Code entered is correct."
Me.txtPoolCode.SetFocus
End If
Thank you,
Draug