How Do You Make an UnBound Control Required?

  • Thread starter Thread starter Rhonda Floyd
  • Start date Start date
R

Rhonda Floyd

I have a unbound control on a form that is required for a make table query to run. What I have is below.

Private Sub txtSource_Exit(Cancel As Integer)
If IsNull(Me.txtSource) Then
MsgBox "Source Code must be entered!"
DoCmd.GoToControl "txtSource"
End If
End Sub

When the control is blank the msgbox pops up, but the cursor goes to the next control. I have to click with the mouse to get back to txtSource control. I also have the InputMask property set to 'AA'.

Any help will be greatly appreciated.
 
Rhonda Floyd said:
I have a unbound control on a form that is required for a make table query to
run. What I have is below.
Private Sub txtSource_Exit(Cancel As Integer)
If IsNull(Me.txtSource) Then
MsgBox "Source Code must be entered!"
DoCmd.GoToControl "txtSource"
End If
End Sub
When the control is blank the msgbox pops up, but the cursor goes to the next
control. I have to click with the mouse to
get back to txtSource control. I also have the InputMask property set to 'AA'.
Any help will be greatly appreciated.

Private Sub txtSource_Exit(Cancel As Integer)
If IsNull(Me.txtSource) Then
MsgBox "Source Code must be entered!"
Cancel = True
End If
End Sub
 
Be aware that people may not just tab into and out of the Control you
require, nor even into the next one. I'll assume, if you are using an
unbound Form for data, that you'll have a Command Button to Save, or,
perhaps, in your case Make Table... the Click event of that Command Button
would be the best place to put this code. I didn't try this with
GoToControl, because I know SetFocus works well:

If IsNull(Me!txtSource) Then
MsgBox "SourceCode is Required"
Me!txtSource.SetFocus
End If

Larry Linson
Microsoft Access MVP


"Rhonda Floyd" wrote in message
I have a unbound control on a form that is required for a make table query
to run. What I have is below.

Private Sub txtSource_Exit(Cancel As Integer)
If IsNull(Me.txtSource) Then
MsgBox "Source Code must be entered!"
DoCmd.GoToControl "txtSource"
End If
End Sub

When the control is blank the msgbox pops up, but the cursor goes to the
next control. I have to click with the mouse to get back to txtSource
control. I also have the InputMask property set to 'AA'.

Any help will be greatly appreciated.



----------------------------------------------------------------------------
----


I have a unbound control on a form that is required for a make table query
to run. What I have is below.

Private Sub txtSource_Exit(Cancel As Integer)
If IsNull(Me.txtSource) Then
MsgBox "Source Code must be entered!"
DoCmd.GoToControl "txtSource"
End If
End Sub

When the control is blank the msgbox pops up, but the cursor goes to the
next control. I have to click with the mouse to get back to txtSource
control. I also have the InputMask property set to 'AA'.

Any help will be greatly appreciated.
 
Back
Top