Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GotoControl

Status
Not open for further replies.

razchip

Technical User
Feb 2, 2001
133
US
I have a form that needs a machine number added before I want the user to go to the next record. The control name is MachNo I have the following code for the On Exit event. When I run it, the message works, but when the form comes back, the cursor moves to the next control. I would like the cursor to remain in the MachNo field.

If [MachNo] > 0 Then
Close
Else
MsgBox "Fill in the Machine #!"
DoCmd.GoToControl "MachNo"
End If

Any suggestions, thanks.

Thanks for the help.
Greg
 
Howzit

How bout

Code:
if isnull(me.machcode) or me.machcode = "" then
    MsgBox "Fill in the Machine #!"
    me.machcode.setfocus
else
end if

Take it Easy
Man with one chopstick go hungry
 
How are ya razchip . . .

The forms [blue]BeforeUpdate[/blue] event is the typical host for this kind of [blue]validation problem[/blue]. So ... in the forms [blue]BeforeUpdate[/blue] event, copy/paste the following:
Code:
[blue]   Dim Msg As String, Style As Integer, Title As String, DL As String
   
   DL = vbNewLine & vbNewLine
   
   If Trim(Me!MachNo & "") = "" Then
      Msg = "'MachNo' is a Required Data Entry!" & DL & _
            "You'll have go back and enter the data . . ."
      Style = vbInformation + vbOKOnly
      Title = "Required Data Entry Missing! . . ."
      MsgBox Msg, Style, Title
      Me!MachNo.SetFocus
      Cancel = True
   End If[/blue]
[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Thanks for the help, got it to work.

Thanks for the help.
Greg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top