Welcome to SPN

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

Sign Up Now!

vbyesno CANCEL??

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

Tags:
  1. lmv

    lmv
    Expand Collapse
    Guest

    Is there a way to "cancel" just close the vb box and go back to the record so
    you can make additional changes (without undoing everything already
    entered)...
    I hope that makes sense. I don't want to say no and trigger the esc type
    event where it goes back to nothing in the record.

    Thanks!
     
  2. Loading...


  3. Jeff Boyce

    Jeff Boyce
    Expand Collapse
    Guest

    I believe you could use:

    vbOKOnly

    to do that.

    Regards

    Jeff Boyce
    Microsoft Office/Access MVP

    "lmv" <lmv@discussions.microsoft.com> wrote in message
    news:1B3F56AD-BD97-4AFC-94EA-B5E4C5E1E08D@microsoft.com...
    > Is there a way to "cancel" just close the vb box and go back to the record
    > so
    > you can make additional changes (without undoing everything already
    > entered)...
    > I hope that makes sense. I don't want to say no and trigger the esc type
    > event where it goes back to nothing in the record.
    >
    > Thanks!
     
  4. lmv

    lmv
    Expand Collapse
    Guest

    I appreciate the response but does that cancel and return you to the record
    with all of the information?
    Here is my code...

    Private Sub Form_BeforeUpdate(Cancel As Integer)
    Dim strMsg As String
    strMsg = "Data has changed."
    strMsg = strMsg & "Do you want to SAVE changes?"
    If MsgBox(strMsg, vbQuestion + vbYesNoCancel, "Save Record?") = vbYes Then
    Me.LastEdited = Now
    'do nothing
    Else
    Me.Undo
    Cancel = True
    End If
    End Sub

    After the Else... how do I make it just close the VB without making any
    changes to already typed info?

    Thanks!

    "Jeff Boyce" wrote:

    > I believe you could use:
    >
    > vbOKOnly
    >
    > to do that.
    >
    > Regards
    >
    > Jeff Boyce
    > Microsoft Office/Access MVP
    >
    > "lmv" <lmv@discussions.microsoft.com> wrote in message
    > news:1B3F56AD-BD97-4AFC-94EA-B5E4C5E1E08D@microsoft.com...
    > > Is there a way to "cancel" just close the vb box and go back to the record
    > > so
    > > you can make additional changes (without undoing everything already
    > > entered)...
    > > I hope that makes sense. I don't want to say no and trigger the esc type
    > > event where it goes back to nothing in the record.
    > >
    > > Thanks!

    >
    >
    >
     
  5. Paul Overway

    Paul Overway
    Expand Collapse
    Guest

    The Yes No Cancel is somewhat redundant, because there are really only 2
    options....yes or no.

    Private Sub Form_BeforeUpdate(Cancel As Integer)

    if msgbox("Save record?",vbyesno)=vbNo then Cancel = True

    'No discard choice for user
    If Cancel Then Me.Undo Else me.LastEdited = Now()

    'Leave discard choice for user
    'If Cancel=false Then me.LastEdited = Now()

    End Sub

    Cancel causes the record to remain in the edited state. If the user wants
    to discard all the changes, they would need to press Esc (twice) or Undo
    (twice). The first Esc or Undo reverts the control to its prior state, the
    2nd Esc or Undo reverts the record to its prior state. Since you're doing
    the Undo programmatically, the user doesn't get a choice to revise the
    entries....they'll get discarded. If you want to give the user the choice,
    see the commented line.

    --
    Paul Overway
    Logico Solutions, LLC
    www.logico-solutions.com


    "lmv" <lmv@discussions.microsoft.com> wrote in message
    news:5D03E9A7-DCB7-45F1-9012-07F7856CFB1C@microsoft.com...
    >I appreciate the response but does that cancel and return you to the record
    > with all of the information?
    > Here is my code...
    >
    > Private Sub Form_BeforeUpdate(Cancel As Integer)
    > Dim strMsg As String
    > strMsg = "Data has changed."
    > strMsg = strMsg & "Do you want to SAVE changes?"
    > If MsgBox(strMsg, vbQuestion + vbYesNoCancel, "Save Record?") = vbYes
    > Then
    > Me.LastEdited = Now
    > 'do nothing
    > Else
    > Me.Undo
    > Cancel = True
    > End If
    > End Sub
    >
    > After the Else... how do I make it just close the VB without making any
    > changes to already typed info?
    >
    > Thanks!
    >
    > "Jeff Boyce" wrote:
    >
    >> I believe you could use:
    >>
    >> vbOKOnly
    >>
    >> to do that.
    >>
    >> Regards
    >>
    >> Jeff Boyce
    >> Microsoft Office/Access MVP
    >>
    >> "lmv" <lmv@discussions.microsoft.com> wrote in message
    >> news:1B3F56AD-BD97-4AFC-94EA-B5E4C5E1E08D@microsoft.com...
    >> > Is there a way to "cancel" just close the vb box and go back to the
    >> > record
    >> > so
    >> > you can make additional changes (without undoing everything already
    >> > entered)...
    >> > I hope that makes sense. I don't want to say no and trigger the esc
    >> > type
    >> > event where it goes back to nothing in the record.
    >> >
    >> > Thanks!

    >>
    >>
    >>
     
  6. lmv

    lmv
    Expand Collapse
    Guest

    Thank you for the help... I will try it tomorrow!

    "Paul Overway" wrote:

    > The Yes No Cancel is somewhat redundant, because there are really only 2
    > options....yes or no.
    >
    > Private Sub Form_BeforeUpdate(Cancel As Integer)
    >
    > if msgbox("Save record?",vbyesno)=vbNo then Cancel = True
    >
    > 'No discard choice for user
    > If Cancel Then Me.Undo Else me.LastEdited = Now()
    >
    > 'Leave discard choice for user
    > 'If Cancel=false Then me.LastEdited = Now()
    >
    > End Sub
    >
    > Cancel causes the record to remain in the edited state. If the user wants
    > to discard all the changes, they would need to press Esc (twice) or Undo
    > (twice). The first Esc or Undo reverts the control to its prior state, the
    > 2nd Esc or Undo reverts the record to its prior state. Since you're doing
    > the Undo programmatically, the user doesn't get a choice to revise the
    > entries....they'll get discarded. If you want to give the user the choice,
    > see the commented line.
    >
    > --
    > Paul Overway
    > Logico Solutions, LLC
    > www.logico-solutions.com
    >
    >
    > "lmv" <lmv@discussions.microsoft.com> wrote in message
    > news:5D03E9A7-DCB7-45F1-9012-07F7856CFB1C@microsoft.com...
    > >I appreciate the response but does that cancel and return you to the record
    > > with all of the information?
    > > Here is my code...
    > >
    > > Private Sub Form_BeforeUpdate(Cancel As Integer)
    > > Dim strMsg As String
    > > strMsg = "Data has changed."
    > > strMsg = strMsg & "Do you want to SAVE changes?"
    > > If MsgBox(strMsg, vbQuestion + vbYesNoCancel, "Save Record?") = vbYes
    > > Then
    > > Me.LastEdited = Now
    > > 'do nothing
    > > Else
    > > Me.Undo
    > > Cancel = True
    > > End If
    > > End Sub
    > >
    > > After the Else... how do I make it just close the VB without making any
    > > changes to already typed info?
    > >
    > > Thanks!
    > >
    > > "Jeff Boyce" wrote:
    > >
    > >> I believe you could use:
    > >>
    > >> vbOKOnly
    > >>
    > >> to do that.
    > >>
    > >> Regards
    > >>
    > >> Jeff Boyce
    > >> Microsoft Office/Access MVP
    > >>
    > >> "lmv" <lmv@discussions.microsoft.com> wrote in message
    > >> news:1B3F56AD-BD97-4AFC-94EA-B5E4C5E1E08D@microsoft.com...
    > >> > Is there a way to "cancel" just close the vb box and go back to the
    > >> > record
    > >> > so
    > >> > you can make additional changes (without undoing everything already
    > >> > entered)...
    > >> > I hope that makes sense. I don't want to say no and trigger the esc
    > >> > type
    > >> > event where it goes back to nothing in the record.
    > >> >
    > >> > Thanks!
    > >>
    > >>
    > >>

    >
    >
    >
     
  7. Jeff Boyce

    Jeff Boyce
    Expand Collapse
    Guest

    I suspect Access HELP provides a more complete description of the action.

    As I understand it, vbOKOnly simply closes the messagebox. That sounds like
    what you are trying to do -- have the user acknowledge the message and then
    proceed with cancelling the update.

    If you are running this in the BeforeUpdate event, you would, as your code
    does, use:
    Cancel = True
    to cancel the update.

    The reason for using the "Undo" is if you want to remove the changes made.

    Regards

    Jeff Boyce
    Microsoft Office/Access MVP

    "lmv" <lmv@discussions.microsoft.com> wrote in message
    news:5D03E9A7-DCB7-45F1-9012-07F7856CFB1C@microsoft.com...
    >I appreciate the response but does that cancel and return you to the record
    > with all of the information?
    > Here is my code...
    >
    > Private Sub Form_BeforeUpdate(Cancel As Integer)
    > Dim strMsg As String
    > strMsg = "Data has changed."
    > strMsg = strMsg & "Do you want to SAVE changes?"
    > If MsgBox(strMsg, vbQuestion + vbYesNoCancel, "Save Record?") = vbYes
    > Then
    > Me.LastEdited = Now
    > 'do nothing
    > Else
    > Me.Undo
    > Cancel = True
    > End If
    > End Sub
    >
    > After the Else... how do I make it just close the VB without making any
    > changes to already typed info?
    >
    > Thanks!
    >
    > "Jeff Boyce" wrote:
    >
    >> I believe you could use:
    >>
    >> vbOKOnly
    >>
    >> to do that.
    >>
    >> Regards
    >>
    >> Jeff Boyce
    >> Microsoft Office/Access MVP
    >>
    >> "lmv" <lmv@discussions.microsoft.com> wrote in message
    >> news:1B3F56AD-BD97-4AFC-94EA-B5E4C5E1E08D@microsoft.com...
    >> > Is there a way to "cancel" just close the vb box and go back to the
    >> > record
    >> > so
    >> > you can make additional changes (without undoing everything already
    >> > entered)...
    >> > I hope that makes sense. I don't want to say no and trigger the esc
    >> > type
    >> > event where it goes back to nothing in the record.
    >> >
    >> > Thanks!

    >>
    >>
    >>
     

Share This Page