Do u want to save changes?... help??

Hi.
first of all, sorry if I put this message in the wrong section!
Im trying to set up my vb form so that when the user exits the form if will bring up a messagebox saying "do you want to save changes" the problem is I dont know the code to use to save or not save information! Can someone please help me??
Thanks.
Cathy

Comments

  • [b][red]This message was edited by the Malcolm at 2002-3-30 18:36:42[/red][/b][hr]
    : Hi.
    : first of all, sorry if I put this message in the wrong section!
    : I’m trying to set up my vb form so that when the user exits the form if will bring up a messagebox saying "do you want to save changes…" the problem is I don’t know the code to use to save or not save information! Can someone please help me??
    : Thanks.
    : Cathy
    :

    Is this the code you are after:

    In the queryunload event:

    [code]Dim Message As Integer
    Message = MsgBox("Do you want to save Changes?", vbYesNoCancel, "Closing")
    If (Message = vbYes) Then
    'Code to save changes
    ElseIf (Message = vbCancel) Then
    Cancel = True
    End If[/code]

    If you want to determine if changes have been made before that question is asked, then I will need to know what type of control you are saving the contents of. With textboxes use this code:

    In declarations section of form:

    [code]Private ChangesMade As Boolean[/code]

    In the change event of the textbox

    [code]ChangesMade = True[/code]

    Then in the query unload event put this code:

    [code]If (ChangesMade = True) Then
    Dim Message As Integer
    Message = MsgBox("Do you want to save Changes?", vbYesNoCancel, "Closing")
    If (Message = vbYes) Then
    'Code to save changes
    ElseIf (Message = vbCancel) Then
    Cancel = True
    End If
    End If[/code]


    Note that you will need to set the variable "ChangesMade" to false whenever the user saves the file, or opens a new document, and maybe there are other occasions as well.






  • Hi Malcolm,
    Thanks a million for answering!
    Yes, the message box with the if then is exactly what I'm looking for!!
    The 'thing' (for want of better word!) I wanna save is a textbox (txtAccDetails) which is bound to a database (datCustomer).

    I would also like to determine if changes are made, but if that's too difficult, It doesn't matter!! I'm kinda new to vb so I'm not good with things that get too complicated...!!

    Thanks a million for ur help :)
    Cathy
  • : Hi Malcolm,
    : Thanks a million for answering!
    : Yes, the message box with the if then is exactly what I'm looking for!!
    : The 'thing' (for want of better word!) I wanna save is a textbox (txtAccDetails) which is bound to a database (datCustomer).
    :
    : I would also like to determine if changes are made, but if that's too difficult, It doesn't matter!! I'm kinda new to vb so I'm not good with things that get too complicated...!!
    :
    : Thanks a million for ur help :)
    : Cathy
    :


    I take it then you would want to know if changes have been made to the textbox. Then the second lot of code I gave in my last post should work.

  • : : Hi Malcolm,
    : : Thanks a million for answering!
    : : Yes, the message box with the if then is exactly what I'm looking for!!
    : : The 'thing' (for want of better word!) I wanna save is a textbox (txtAccDetails) which is bound to a database (datCustomer).
    : :
    : : I would also like to determine if changes are made, but if that's too difficult, It doesn't matter!! I'm kinda new to vb so I'm not good with things that get too complicated...!!
    : :
    : : Thanks a million for ur help :)
    : : Cathy
    : :
    :
    :
    : I take it then you would want to know if changes have been made to the textbox. Then the second lot of code I gave in my last post should work.
    :
    :
    she is working with a database i forget what the data base object is to detect changes but i know that if you want to cancel the update you do something like datMyDatabase.CancelUpdate I will look and see if i can find what you need to check if changes have been made.
  • : : : Hi Malcolm,
    : : : Thanks a million for answering!
    : : : Yes, the message box with the if then is exactly what I'm looking for!!
    : : : The 'thing' (for want of better word!) I wanna save is a textbox (txtAccDetails) which is bound to a database (datCustomer).
    : : :
    : : : I would also like to determine if changes are made, but if that's too difficult, It doesn't matter!! I'm kinda new to vb so I'm not good with things that get too complicated...!!
    : : :
    : : : Thanks a million for ur help :)
    : : : Cathy
    : : :
    : :
    : :
    : : I take it then you would want to know if changes have been made to the textbox. Then the second lot of code I gave in my last post should work.
    : :
    : :
    : she is working with a database i forget what the data base object is to detect changes but i know that if you want to cancel the update you do something like datMyDatabase.CancelUpdate I will look and see if i can find what you need to check if changes have been made.
    :

    I was wondering about that, except she said she wanted to save the textbox. Anyway you would know the code for a database better, as I've as good as done no programming with databases.


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories