How Do You Make an UnBound Control Required?

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.
 
R

Rick Brandt

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
 
L

Larry Linson

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top