Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Stop procedures

Discussion in 'Information Technology' started by an, Jul 28, 2006.

  1. an

    an
    Expand Collapse
    Guest

    Hi!

    I have one msgbox to inform the lack of fulfilling of a field.
    I used:
    If IsNull (Me.txtField1) Then
    MsgBox “.......“
    End If

    Work fine but after the acknowledgment, it continues with the procedures.
    It would like that it interrupted the procedure until the field was filled.

    Thanks in advance.
    an
     
  2. Loading...


  3. Wayne Morgan

    Wayne Morgan
    Expand Collapse
    Guest

    Where have you placed this code? A good place for it would be in the form's
    BeforeUpdate event. If it is located there, a couple of small modifications
    should do the trick.

    > If IsNull (Me.txtField1) Then
    > MsgBox "......."

    Cancel = True
    Me.txtField1.SetFocus
    Exit Sub
    > End If



    --
    Wayne Morgan
    MS Access MVP


    "an" <an@discussions.microsoft.com> wrote in message
    news:617E7C92-FD5B-4FBE-BD35-94146BD34206@microsoft.com...
    > Hi!
    >
    > I have one msgbox to inform the lack of fulfilling of a field.
    > I used:
    > If IsNull (Me.txtField1) Then
    > MsgBox "......."
    > End If
    >
    > Work fine but after the acknowledgment, it continues with the procedures.
    > It would like that it interrupted the procedure until the field was
    > filled.
    >
    > Thanks in advance.
    > an
     
  4. an

    an
    Expand Collapse
    Guest

    Sorry my delay.

    I had the code in "on click" of the command button in main form to run
    update query.
    Now, in "before update" of the Sub Form, the code work but run after the
    code in command button what it does not produce the effect desired.

    Thanks an

    "Wayne Morgan" wrote:

    > Where have you placed this code? A good place for it would be in the form's
    > BeforeUpdate event. If it is located there, a couple of small modifications
    > should do the trick.
    >
    > > If IsNull (Me.txtField1) Then
    > > MsgBox "......."

    > Cancel = True
    > Me.txtField1.SetFocus
    > Exit Sub
    > > End If

    >
    >
    > --
    > Wayne Morgan
    > MS Access MVP
    >
    >
    > "an" <an@discussions.microsoft.com> wrote in message
    > news:617E7C92-FD5B-4FBE-BD35-94146BD34206@microsoft.com...
    > > Hi!
    > >
    > > I have one msgbox to inform the lack of fulfilling of a field.
    > > I used:
    > > If IsNull (Me.txtField1) Then
    > > MsgBox "......."
    > > End If
    > >
    > > Work fine but after the acknowledgment, it continues with the procedures.
    > > It would like that it interrupted the procedure until the field was
    > > filled.
    > >
    > > Thanks in advance.
    > > an

    >
    >
    >
     
  5. Wayne Morgan

    Wayne Morgan
    Expand Collapse
    Guest

    In the Click event of a command button, remove the "Cancel=True" line, the
    other two new lines should still work for you.

    --
    Wayne Morgan
    MS Access MVP


    "an" <an@discussions.microsoft.com> wrote in message
    news:320924A3-A4AD-4766-A854-44E7B12A58C0@microsoft.com...
    > Sorry my delay.
    >
    > I had the code in "on click" of the command button in main form to run
    > update query.
    > Now, in "before update" of the Sub Form, the code work but run after the
    > code in command button what it does not produce the effect desired.
     
  6. an

    an
    Expand Collapse
    Guest

    WM,

    Thanks for your reply.
    Return us:
    "...can't move the focus to the control txtField1"

    Thanks.
    an

    "Wayne Morgan" wrote:

    > In the Click event of a command button, remove the "Cancel=True" line, the
    > other two new lines should still work for you.
    >
    > --
    > Wayne Morgan
    > MS Access MVP
    >
    >
    > "an" <an@discussions.microsoft.com> wrote in message
    > news:320924A3-A4AD-4766-A854-44E7B12A58C0@microsoft.com...
    > > Sorry my delay.
    > >
    > > I had the code in "on click" of the command button in main form to run
    > > update query.
    > > Now, in "before update" of the Sub Form, the code work but run after the
    > > code in command button what it does not produce the effect desired.

    >
    >
    >
     
  7. Wayne Morgan

    Wayne Morgan
    Expand Collapse
    Guest

    Where is the button located? Are the button and textbox on the same form or
    is one of them on a subform? Setting the focus to the textbox is nice, but
    not necessary. The user can navigate to on their own.

    --
    Wayne Morgan
    MS Access MVP


    "an" <an@discussions.microsoft.com> wrote in message
    news:5FA3766D-BBCB-4149-AFE2-C4B3444921F7@microsoft.com...
    > WM,
    >
    > Thanks for your reply.
    > Return us:
    > "...can't move the focus to the control txtField1"
    >
    > Thanks.
    > an
    >
    > "Wayne Morgan" wrote:
    >
    >> In the Click event of a command button, remove the "Cancel=True" line,
    >> the
    >> other two new lines should still work for you.
    >>
    >> --
    >> Wayne Morgan
    >> MS Access MVP
    >>
    >>
    >> "an" <an@discussions.microsoft.com> wrote in message
    >> news:320924A3-A4AD-4766-A854-44E7B12A58C0@microsoft.com...
    >> > Sorry my delay.
    >> >
    >> > I had the code in "on click" of the command button in main form to run
    >> > update query.
    >> > Now, in "before update" of the Sub Form, the code work but run after
    >> > the
    >> > code in command button what it does not produce the effect desired.

    >>
    >>
    >>
     
  8. an

    an
    Expand Collapse
    Guest

    Yes, the textbox and command button they are on same subForm.
    Thanks
    Is necessary the same code in OnClick the command button and BeforeUpdate,
    both in subForm, please?

    an

    "Wayne Morgan" wrote:

    > Where is the button located? Are the button and textbox on the same form or
    > is one of them on a subform? Setting the focus to the textbox is nice, but
    > not necessary. The user can navigate to on their own.
    >
    > --
    > Wayne Morgan
    > MS Access MVP
    >
    >
    > "an" <an@discussions.microsoft.com> wrote in message
    > news:5FA3766D-BBCB-4149-AFE2-C4B3444921F7@microsoft.com...
    > > WM,
    > >
    > > Thanks for your reply.
    > > Return us:
    > > "...can't move the focus to the control txtField1"
    > >
    > > Thanks.
    > > an
    > >
    > > "Wayne Morgan" wrote:
    > >
    > >> In the Click event of a command button, remove the "Cancel=True" line,
    > >> the
    > >> other two new lines should still work for you.
    > >>
    > >> --
    > >> Wayne Morgan
    > >> MS Access MVP
    > >>
    > >>
    > >> "an" <an@discussions.microsoft.com> wrote in message
    > >> news:320924A3-A4AD-4766-A854-44E7B12A58C0@microsoft.com...
    > >> > Sorry my delay.
    > >> >
    > >> > I had the code in "on click" of the command button in main form to run
    > >> > update query.
    > >> > Now, in "before update" of the Sub Form, the code work but run after
    > >> > the
    > >> > code in command button what it does not produce the effect desired.
    > >>
    > >>
    > >>

    >
    >
    >
     
  9. Wayne Morgan

    Wayne Morgan
    Expand Collapse
    Guest

    No, don't necessarily need this code in both the button's Click and the
    form's BeforeUpdate. Use whichever you want to catch the missing data (one
    or both). The advantage of the BeforeUpdate is that if someone tries to save
    the record without using the button, it will still catch the missing data.

    I just tried to make sure and I can set the focus to a textbox on a subform
    from the click event of a button on that same subform using the code
    previously listed.

    Do they both need to be on the same subform? No, but the syntax of the code
    changes if they aren't.

    --
    Wayne Morgan
    MS Access MVP


    "an" <an@discussions.microsoft.com> wrote in message
    news:77D8335B-5557-4AF8-B9DB-798781122D8A@microsoft.com...
    > Yes, the textbox and command button they are on same subForm.
    > Thanks
    > Is necessary the same code in OnClick the command button and BeforeUpdate,
    > both in subForm, please?
     
  10. an

    an
    Expand Collapse
    Guest

    Ok, WM.

    Problem solved. Work fine.
    Thank you for your help and sorry for my delay.
    (I was "out"...)

    an

    "Wayne Morgan" wrote:

    > No, don't necessarily need this code in both the button's Click and the
    > form's BeforeUpdate. Use whichever you want to catch the missing data (one
    > or both). The advantage of the BeforeUpdate is that if someone tries to save
    > the record without using the button, it will still catch the missing data.
    >
    > I just tried to make sure and I can set the focus to a textbox on a subform
    > from the click event of a button on that same subform using the code
    > previously listed.
    >
    > Do they both need to be on the same subform? No, but the syntax of the code
    > changes if they aren't.
    >
    > --
    > Wayne Morgan
    > MS Access MVP
    >
    >
    > "an" <an@discussions.microsoft.com> wrote in message
    > news:77D8335B-5557-4AF8-B9DB-798781122D8A@microsoft.com...
    > > Yes, the textbox and command button they are on same subForm.
    > > Thanks
    > > Is necessary the same code in OnClick the command button and BeforeUpdate,
    > > both in subForm, please?

    >
    >
    >
     

Share This Page